akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string s, t;
  cin >> s >> t;

  int n = s.size();
  int m = t.size();
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i] == t[j]) {
        chmax(dp[i + 1][j + 1], dp[i][j] + 1);
      }
      chmax(dp[i + 1][j + 1], dp[i + 1][j]);
      chmax(dp[i + 1][j + 1], dp[i][j + 1]);
    }
  }

  string ans;

  int i = n;
  int j = m;
  while (i > 0 && j > 0) {
    if (dp[i - 1][j] == dp[i][j]) {
      i--;
    } else if (dp[i][j - 1] == dp[i][j]) {
      j--;
    } else {
      i--;
      j--;
      ans += s[i];
    }
  }

  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


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

int main(){
	int n; cin>>n;
	ll ans=1;
	for(ll i=1; i<=n; i++){
		ans=(ans*i)%m;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

ll N, K, R, S, P;
string T;

ll judge(char c){
    if(c=='r')return P;
    else if(c=='s')return R;
    else if(c=='p') return S;
    return 0;
}

int main(void)
{
    char now, bef;
    ll ans=0;
    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;
    for(ll i=0;i<K;i++){
        now = bef = T[i];
        ans += judge(now);
        for(ll j=i+K;j<=N;j+=K){
            now = T[j];
            if(now==bef){
                bef = 'a';
                continue;
            }
            else{
                ans += judge(now);
                bef = now;
            }
        }
    }
    cout << ans << endl;
}


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

ll divisor(long long a) {
    ll ans = 1;
    for (ll i = 2; i * i <= a; i++) {
    int cnt = 0;
    while (a % i == 0) {
      cnt++;
      a /= i;
    }
    ans *= (cnt + 1);
    if (a == 1) break;
  }
  if (a != 1) ans *= 2;

  return ans;
}

int main(){
    ll n; cin >> n;
    
    ll ans = 0;
    for(ll i = 1; i < n + 1; i ++){
        ll ue = n - i;
        ll div = divisor(ue);
        ans += div;
    }

    cout << ans - 2 << endl;

}

Measured memory_bytes: 3620
#include <cstdio>

int fibonacci(int* fib, int n){
    if(n<=1)return 1;
    if(fib[n]>0)return fib[n];
    fib[n] = fibonacci(fib, n-1) + fibonacci(fib, n-2);
    return fib[n];
}

int main(){
    int i, n, fib[45];
    for(i=0;i<45;i++){
        fib[i]=-1;
    }
    scanf("%d",&n);
    printf("%d\n",fibonacci(fib, n));
    return 0;
}



Measured memory_bytes: 2700
#include<stdio.h>
int main(void)
{
	char S[20];
	scanf("%s",&S);
	if(S[0]=='S') 
	{
		printf("Cloudy\n");
	}
	else if(S[0]=='C')
	{
		printf("Rainy\n");
	}
	else if(S[0]=='R') 
	{
		printf("Sunny\n");
	}
	return 0;
}


Measured memory_bytes: 128
S = input().replace('BC', 'D')

def calculate(d_position):
    result = sum(d_position)
    result -= (len(d_position) * (len(d_position) - 1)) // 2
    return result

#print(S)
d_position = []
counter = 0
prev = ''
is_candidate = False
for s in S:
    if not is_candidate and s == 'A':
        #print('start')
        is_candidate = True
        prev = 'A'
    elif is_candidate:
        if s == 'B' or s == 'C':
            # print('end')
            counter += calculate(d_position)
            is_candidate = False
            d_position = []
            prev = ''
        else:
            prev += s
            if s == 'D':
                d_position.append(len(prev)-1)
if is_candidate:
    counter += calculate(d_position)
print(counter)

Measured memory_bytes: 5916
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;

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

    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }

    exrep(i, k, n-1) {
        if(a[i] > a[i-k]) {
            out("Yes");
        }
        else {
            out("No");
        }
    }
    
    re0;
}

Measured memory_bytes: 4840
#include<cstdio>
#include<cmath>
int m=99,n,w[12]={1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
void dfs(int p,int s,int c)
{
	if(s==n)m=m<c?m:c;
	else if(p--)for(int i=0;i<6&&s+w[p]*i<=n;++i)dfs(p,s+w[p]*i,c+i);
}
int main()
{
	scanf("%d",&n);
	dfs(12,0,0);
	printf("%d",m);
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A, B;
  cin >> A >> B;
  cout << max(0, A - B * 2) << 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 RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  ll ans=1;
  for (int i=1; i<=n; i++) {
    ans = (ans*i)%mod;
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#abc049 c
s=input()
divide=["dream","dreamer","erase","eraser"]

s=s[::-1]
for i,x in enumerate(divide):
    divide[i]=x[::-1]

ans=True
i=0
while i<len(s):
    flag=False
    for x in divide:
        lx=len(x)
        if s[i:i+lx] in divide:
             flag=True
             i+=lx
    if flag==False:
        ans=False
        break
if flag:
     print("YES")
else:
     print("NO")


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

int h1, m1, h2, m2, k;

int main () {
	scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
	printf("%d\n", (h2 * 60 + m2) - (h1 * 60 + m1) - k);
	return 0;
}

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

class Main
{
	public static void main(String[] args)
	{
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

		for(int i=0; i<10; ++i){
			for(int j=0; j<10; ++j){
				if(!map.containsKey(i+j))
					map.put(i+j, 1);
				else
					map.put(i+j, map.get(i+j)+1);
			}
		}

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
		String str;

		try{
			while((str = bf.readLine()) != null){
				int ans = 0;
				int n = Integer.parseInt(str);
				for(Map.Entry<Integer, Integer> e : map.entrySet()){
					Integer v = map.get(n-e.getKey());
					ans += (v==null ? 0 : v) * e.getValue();
				}
				System.out.println(ans);
			}
		}
		catch(IOException ex){
			System.out.println(ex);
		}
	}
}

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n;
int main(){
	char x;
	scanf(" %c",&x);
	int y=x;
	y++;
	char q=y;
	cout<<q;
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
  int N, a, aa;
  long long dai;
  dai = 0;
  cin >> N;
  cin >> a;
  for (int i = 1; i < N; i++) {
    cin >> aa;
    int step = a - aa;
    if (step > 0) {
      dai += step;
    } else {
      step = 0;
    }
    a = aa + step;
  }
  cout << dai;
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k,n;
  cin >> k >> n;
  int  a[n]={};
  for(int i=0;i<n;i++){
      cin >> a[i];
  }
  int max1 = 0;
  int sa1=0,sa2=0;
  int count = 0;
  for(int i=1;i<n;i++){
      int sa = a[i]-a[i-1];
      count += sa;
      if(max1<sa){
        sa1 = a[i-1];
        sa2 = a[i];
        max1 = sa;
      }
  }
  cout << min(count,(sa1+(k-sa2))) << endl;
}


Measured memory_bytes: 1152
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def use(d,sum,cost,max)
  if(d > $d)
    $buf.push([sum, cost, max])
    return
  end
  use(d+1,sum+$t[d-1][1]+d*100*$t[d-1][0],cost+$t[d-1][0],max)
  use(d+1,sum,cost,d)
end
$buf = []
$t = []
$d, $g = inp
$d.times{$t<<inp}
use(1,0,0,0)
min = 1e100
$buf.each do |sum,cost,max|
  now = $g - sum
  $t[max-1][0].times do |i|
    break if(now <= 0)
    now -= max*100
    cost += 1
  end
  min = [min,cost].min if(now <= 0)
end
p min

Measured memory_bytes: 1788
import numpy as np
n, d = list(map(int, input().split()))
x = []
y = []
dist = lambda x,y: np.sqrt(x**2+y**2)
for _ in range(n):
    tmp = list(map(int, input().split()))
    x.append(tmp[0])
    y.append(tmp[1])
count = 0
for x_,y_ in zip(x,y):
    if (dist(x_,y_)<= d): count +=1
print(count)


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

class Splitter {
	string m_str;
	vector<string> m_res;
	vector<int> m_cpos;

public:
	Splitter( const string& s ): m_str( s ) {}

	void split( int n, int beg = 0 ) {
		if( n == 0 ) {
			cut();
			return;
		}

		int len = m_str.size() - beg - n;

		for( int i = 0; i < len; ++i ) {
			m_cpos.push_back( beg + i + 1 );
			split( n - 1, beg + i + 1 );
			m_cpos.pop_back();
		}
	}

	void cut() {
		int p = 0;

		for( int i = 0; i < m_cpos.size(); ++i ) {
			m_res.push_back( m_str.substr( p, m_cpos[i]-p ) );
			p = m_cpos[i];
		}

		m_res.push_back( m_str.substr(p) );
	}

	long long sum() const {
		long long r = 0;

		for( auto&& s: m_res ) {
			r += stoll(s);
		}

		return r;
	}

	void reset() {
		m_res.clear();
		m_cpos.clear();
	}
};

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

	Splitter spl( S );
	long long sum = 0;

	for( int i = 0; i < S.size(); ++i ) {
		spl.split( i );
		sum += spl.sum();

		spl.reset();
	}

	cout << sum << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			if(op.contentEquals("?"))break;
			int ans = 0;
			if(op.contentEquals( "+")){
				ans = a+b;
			}else if(op.contentEquals("-")){
				ans = a-b;
			}else if(op.contentEquals("*")){
				ans = a*b;
			}else if(op.contentEquals("/")){
				ans = a/b;
			}
			System.out.println(ans);
		}
	}
}



Measured memory_bytes: 26132
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A == B && A != C) {
    cout << "Yes" << endl;
    return 0;
  }
  if (A != B && A == C) {
    cout << "Yes" << endl;
    return 0;
  }
  if (A != C && B == C) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}


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

const int mod = 1e9+7, maxn = 2000010;
int r1, c1, r2, c2;

ll pre[maxn];
ll inv[maxn];
ll prei[maxn];

void build(int n){
    pre[1] = pre[0] = 1, inv[1] = inv[0] = 1, prei[1] = prei[0] = 1;
    for(int i = 2 ; i <= n ; i++){
        pre[i] = pre[i-1] * i % mod;
        //inv[i] = (mod - mod / i * inv[mod % i] % mod) % mod;
        inv[i] = (mod - mod / i * inv[mod % i]) % mod;
        prei[i] = prei[i-1] * inv[i] % mod;
    }
}

ll C(int n, int k){
   return pre[n] * prei[k] % mod * prei[n-k] % mod;
}

ll solve(int x, int y){
    if (x == 0 || y == 0) return 0;
    ll ret = 0;
    for (int i = 1; i <= y; i++){
        ret += C(x+i+1, i+1);
    }
    ret -= y;
    return ret % mod;
}

int main(){
    build(2000005);
    cin >> r1 >> c1 >> r2 >> c2;
    cout << (solve(r2, c2)-solve(r1-1, c2)-solve(r2, c1-1)+solve(r1-1, c1-1)+mod*2)%mod << "\n";
    //cout << (solve(r2, c2)-solve(r1-1, c2)-solve(r2, c1-1)+solve(r1-1, c1-1))%mod << "\n";
}

Measured memory_bytes: 47104
import sys
readline = sys.stdin.buffer.readline

s = readline().rstrip().decode('utf-8')

for i in range(1,len(s)):
    if s[i] == s[i-1]:
        print(i,i+1)
        exit()
for i in range(2,len(s)):
    if s[i] == s[i-2]:
        print(i-1,i+1)
        exit()
print(-1,-1)

Measured memory_bytes: 39540
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int h, w, ans = 0;
    scanf("%d%d", &h, &w);
    vector< vector<char> > s(h + 2, vector<char>(w + 2));
    vector< vector< vector<int> > > m(h + 2, vector< vector<int> >(w + 2, vector<int>(4)));
    for (int i = 1; i <= h; ++i) scanf("%s", &s.at(i).at(1));
    for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) if (s.at(i).at(j) == '.') m.at(i).at(j).at(0) = m.at(i).at(j - 1).at(0) + 1;
    for (int i = 1; i <= h; ++i) for (int j = w; j >= 1; --j) if (s.at(i).at(j) == '.') m.at(i).at(j).at(1) = m.at(i).at(j + 1).at(1) + 1;
    for (int j = 1; j <= w; ++j) for (int i = 1; i <= h; ++i) if (s.at(i).at(j) == '.') m.at(i).at(j).at(2) = m.at(i - 1).at(j).at(2) + 1;
    for (int j = 1; j <= w; ++j) for (int i = h; i >= 1; --i) if (s.at(i).at(j) == '.') m.at(i).at(j).at(3) = m.at(i + 1).at(j).at(3) + 1;
    for (int i = 1; i <= h; ++i) for (int j = 1; j <= w; ++j) if (s.at(i).at(j) == '.') ans = max(ans, accumulate(m.at(i).at(j).begin(), m.at(i).at(j).end(), 0) - 3);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 223616
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int S, T; cin >> S >> T; S--, T--;
        G[S].push_back(T);
    }
    vector<double> X(N);
    for (int node = N - 2; node >= 0; node--) {
        double sum = 0;
        for (int next : G[node]) sum += X[next];
        X[node] = 1 + sum / G[node].size();
    }
    double ans = X[0];
    for (int node = N - 2; node >= 0; node--) {
        if (G[node].size() == 1) continue;
        vector<double> Y = X;
        double sum = 0, ma = 0;
        for (int next : G[node]) {
            sum += Y[next];
            ma = max(ma, Y[next]);
        }
        Y[node] = 1 + (sum - ma) / (G[node].size() - 1);
        for (int n = node - 1; n >= 0; n--) {
            sum = 0;
            for (int next : G[n]) sum += Y[next];
            Y[n] = 1 + sum / G[n].size();
        }
        ans = min(ans, Y[0]);
    }
    cout << fixed << setprecision(9) << ans << endl;
    return 0;
}


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

int main() {
	int n, x;
	cin >> n >> x;
	int m[100];

	int d = 0;
	int min;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		if (i == 0)min = m[i];
		else if (m[i] < min)min = m[i];
		x -= m[i];
		d++;
	}
	d += (x / min);
	cout << d;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<vector<int> >&adj,vector<bool> &vis,int i)
{
  if(vis[i]==true)
    return;
  vis[i]=true;
  for(int x:adj[i])
  {
    if(!vis[x])
      dfs(adj,vis,x);
  }
}
int main()
{
  int n,m,a,b,ans=0;
  cin>>n>>m;
  vector<bool> vis(n+1,false);
  vector<vector<int> >adj(n+1);
  for(int i=0;i<m;i++)
  {
    cin>>a>>b;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  for(int i=1;i<=n;i++)
  {
    if(vis[i]==false)
    {
      ans++;
      dfs(adj,vis,i);
    }
  }
  cout<<ans-1;
  return 0;
}


Measured memory_bytes: 9580
# -*- coding: utf-8 -*-

n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))

vc = []
for i in range(n):
    vc.append(v[i]-c[i])

ans = 0
for i in range(n):
    if vc[i] > 0:
        ans += vc[i]

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<set>
#include<list>
using namespace std;

int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}
signed main() {
	int a, b; cin >> a >> b;
	cout << gcd(a, b) << endl;
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  sort(a, a + 3);

  // 解答
  cout << a[2] * 10 + a[1] + a[0] << endl;
  return 0;
}


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

int main() {
  int x;
  cin >> x;
  if (x >= 10000) cout << 1 << endl;
  else {
    int a = x  / 100, b = x % 100;
    if (b <= a * 5) cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

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

using namespace std;

int main(){
        int cnt[100]={0};
        int N, M;
        cin>>N>>M;
        for(int i=0;i<M;i++){
                int a, b;
                cin>>a>>b;
                cnt[a]++;cnt[b]++;
        }
        for(int i=1;i<=N;i++){
                cout<<cnt[i]<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
import Data.List -- sort
import Control.Monad -- replicateM

readInt = read <$> getLine :: IO Integer
arrayInt = map read . words <$> getLine :: IO [Integer]
writeln x = putStrLn $ unwords x :: IO ()

main = do
    n <- readInt
    v <- arrayInt
    c <- arrayInt
    print $ sum $ filter (0<) $ map (\(x,y) -> x - y) $ zip v c


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

int main(){
    
    long long a,i,sum=1;
    cin>>a;
    for(i=1;i<=a;i++){
        sum=sum*i;
        sum=sum%1000000007;
    }
    
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

int main(void){
    string s;
    cin >> s;
    if(s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
public class Main{
public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
   int r=0;;
int low = 1000;
int m = n%low;
if(m==0){
    System.out.println(0);
}else{
 r = 1000-m;
 System.out.println(r);
}


}
}

Measured memory_bytes: 35528
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 整数の入力
    a <- readLn
    -- 出力
    putStrLn $ if a >= 1200 then "ARC" else "ABC"


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

int main(void){
    int a,b,m,c = 0,d;
    cin >> a >> b >> m;
    if(a < b)d = a;
    else d = b;
    for(int i = d;i > 0;i--){
        if(a % i == 0 && b % i == 0)c++;
        if(c == m){
            cout << i;
            break;
        }
    }
}

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

int main(void) {
    int A,B,K;

      cin >> A>>B>>K;

      for(int i=A;i<=B;i++){
        if((i<A+K)||(i>B-K))
        cout<< i << endl ;
      }


    return 0;
}


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

using namespace std;

int main(){
    int a[3];
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    int count = 0;
    if(a[0] == a[1]){
        count++;
    }
    if(a[1] == a[2]){
        count++;
    }
    if(a[2] == a[0]){
        count++;
    } 
    if(count == 1){
        cout << "Yes" << endl;
    }
    else 
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 500005
using namespace std;

int n, m, x, y, cnt, a[N], c[N], b[N];
int main()
{
	int i;
	cin >> n >> m;
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		c[a[i]]++;
		b[max(0, a[i] - c[a[i]])]++;
	}
	for (i = 0; i < n; i++) if (!b[i]) cnt++;
	while (m--) {
		scanf("%d %d", &x, &y);
		b[max(0, a[x] - c[a[x]])]--;
		if (b[max(0, a[x] - c[a[x]])] == 0) cnt++;
		c[a[x]]--;
		c[y]++;
		if (b[max(0, y - c[y])] == 0) cnt--;
		b[max(0, y - c[y])]++;
		a[x] = y;
		printf("%d\n", cnt);
	}
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <climits>
#include <cmath>

int main(){
  int n;
  std::cin >> n;
  long long dp[3];
  for(int j=0;j<3;j++)
    dp[j] = 0;
  //long long* h = new long long[n];
  long long dpn[3];
  long long a[3];
  for(int i=0;i<n;i++){
    std::cin >> a[0] >> a[1] >> a[2];
    for(int j=0;j<3;j++)
      dpn[j] = 0;
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if (j != k)
          dpn[k] = std::max(dpn[k],dp[j]+a[k]);
      }
    }
    for(int j=0;j<3;j++)
      dp[j] = dpn[j];
    //d[i] = LLONG_MAX;//INT_MAX;
  }
  
  long long res = dp[0];
  if (res < dp[1])
    res = dp[1];
  if (res < dp[2])
    res = dp[2];
  std::cout << res << std::endl;
  
  //delete h;
  //delete d;
  return 0;
}


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

const int INF = 30*30+1;
const int NOTUSE = 400*100;

struct Vec3{
  int x;
  int y;
  int count;
  Vec3(){
    x=0;
    y=0;
    count=1;
  }
};

int main(){

    int w,h;
    while(1){
      cin >> w >> h;
      if(w==0&&h==0){
        break;
      }
      char table[w][h];
      int counttable[w][h];
      bool hwall[w][h],wwall[w][h];
      int input;

      for(int i=0;i<w;i++){
        for(int j=0;j<h;j++){
          table[i][j] = '*';
          counttable[i][j] = INF;
          wwall[i][j] = true;
          hwall[i][j] = true;
        }
      }

      for(int i=0;i<h;i++){

        for(int j=0;j<w-1;j++){
          cin >> input;
          if(input==1){
            hwall[j][i] = false;
          }
        }
        if(i==h-1){
          break;
        }
        for(int j=0;j<w;j++){
          cin >> input;
          if(input==1){
            wwall[j][i] = false;
          }
        }
      }

      queue<Vec3> q;

      Vec3 vec,tmp;
      q.push(vec);
      while(!q.empty()){
        vec = q.front();
        q.pop();

        if(table[vec.x][vec.y]=='.'){
          continue;
        }

        table[vec.x][vec.y]='.';



        if(counttable[vec.x][vec.y] > vec.count){
          counttable[vec.x][vec.y] = vec.count;
        }

        vec.count += 1;
        tmp = vec;
        if(vec.x > 0 && hwall[vec.x-1][vec.y]){
          tmp.x = vec.x - 1;
          tmp.y = vec.y;
          q.push(tmp);
          tmp = vec;
        }

        if(vec.x < w-1 && hwall[vec.x][vec.y]){
          tmp.x = vec.x + 1;
          tmp.y = vec.y;
          q.push(tmp);
          tmp = vec;
        }

        if(vec.y < h-1 && wwall[vec.x][vec.y]){
          tmp.x = vec.x;
          tmp.y = vec.y + 1;
          q.push(tmp);
          tmp = vec;
        }

        if(vec.y > 0 && wwall[vec.x][vec.y-1]){
          tmp.x = vec.x;
          tmp.y = vec.y - 1;
          q.push(tmp);
          tmp = vec;
        }


      }


      if(counttable[w-1][h-1] == INF){
        counttable[w-1][h-1] = 0;
      }
      cout << counttable[w-1][h-1] << endl;

    }




    return 0;
}

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

int main(){
    int n, q, ans=0;
    cin >> n;
    int S[n];
    for(int i=0 ; i<n ; i++){
        cin >> S[i];
    }
    cin >> q;
    int T[q];
    for(int j=0 ; j<q ; j++){
        cin >> T[j];
    }
    for(int k=0 ; k<q ; k++){
        int left=0, right=n, mid;
        while(left<right){
            mid=(left+right)/2;
            if(T[k]==S[mid]){
                ans++;
                break;
            }else if(T[k]<S[mid]){
                right=mid;
            }else{
                left=mid+1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [[] for _ in range(N)]
count = 0
for _ in range(M):
  a,b = map(int,input().split())
  AB[a-1].append(H[b-1])
  AB[b-1].append(H[a-1])
for i in range(N):
  AB[i].sort()
for i in range(N):
  if AB[i] == []:
    count += 1
  elif H[i] > AB[i][-1]:
    count += 1
print(count)

Measured memory_bytes: 23388
#include<iostream>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<cmath>
#include<list>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 200000 + 8;


int n,a[maxn];
ll num = 0;

void Merge(int a[],int left,int mid,int right,int temp[])
{
    int i = left,j = mid + 1, cur = 0;
    //cout << left << " "<< mid <<" "<< right << " " << n1 <<endl;
    while(i <= mid && j <= right)
    {
        if(a[i] <= a[j]) {
            temp[cur++] = a[i++];
        } else{
            temp[cur++] = a[j++];
            num += mid - i + 1;
        }
    }

    while(i <= mid) temp[cur++] = a[i++];
    while(j <= right) temp[cur++] = a[j++];

    for(int z = 0; z < cur; ++z)
    {
        a[left + z] = temp[z];
    }
}
void MergeSort(int a[],int left,int right,int temp[])
{
    if(left < right)
    {
        int mid = (right + left) / 2;
        MergeSort(a, left, mid, temp);
        MergeSort(a, mid+1, right, temp);
        Merge(a,left,mid,right, temp);
    }
}
int main()
{
    scanf("%d",&n);
    for(int i = 0; i < n; ++i)
        scanf("%d",&a[i]);

    int temp[maxn];
    MergeSort(a, 0, n-1,temp);
    printf("%lld\n", num);
    return 0;
}

/*
5
3 5 2 1 4
6
3 5 2 6 1 4
*/

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, L; cin >> N >> L;
    string S[N]; rep(i, N) cin >> S[i]; sort(S, S+N);
    rep(i, N) cout << S[i]; cout << endl;
    return 0;
}

Measured memory_bytes: 256
import math
of = 10**9+7
n,m = map(int,input().split())
if abs(n-m) >= 2:
    print(0)
    exit()
if n == m:
    print(math.factorial(n)*math.factorial(m)*2 % of)
else:
    print(math.factorial(n)*math.factorial(m) % of)

Measured memory_bytes: 10748
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 200005
#define eps 1e-10
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
char s[MAXN];
int sum[MAXN],N;
int dp[MAXN];
map<int,int> zz;
void Init() {
	scanf("%s",s + 1);
	N = strlen(s + 1);
	for(int i = 1 ; i <= N ; ++i) {
		sum[i] = sum[i - 1];
		sum[i] ^= (1 << s[i] - 'a');
	}
}
void Solve() {
	zz[0] = 0;
	for(int i = 1 ; i <= N ; ++i) {
		dp[i] = i;
		if(zz.count(sum[i])) dp[i] = min(dp[i],zz[sum[i]] + 1);
		for(int j = 0 ; j < 26 ; ++j) {
			if(zz.count(sum[i] ^ (1 << j))) dp[i] = min(dp[i],zz[sum[i] ^ (1 << j)] + 1);
		}
		if(!zz.count(sum[i])) zz[sum[i]] = dp[i];
		else zz[sum[i]] = min(zz[sum[i]],dp[i]);
	}
	out(dp[N]);enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Init();
	Solve();
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 60;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    int ans = 0;
    rep(i, 4){
        if(S[i] == '-') ans--;
        else ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parents = [i for i in range(n + 1)]
        self.sizes = [1] * (n + 1)
 
    def find(self, x):
        if self.parents[x] == x:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
 
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if y < x:
            x, y = y, x
        self.parents[y] = x
        self.sizes[x] += self.sizes[y]
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
 
    def size(self, x):
        return self.sizes[self.find(x)]

def main():
    n, m, k = map(int, input().split())
    uf = UnionFind(n)
    friends = [0] * n
    blocks = [0] * n
    for i in range(m):
        a, b = map(int, input().split())
        friends[a - 1] += 1
        friends[b - 1] += 1
        uf.unite(a - 1, b - 1)
    for i in range(k):
        c, d = map(int, input().split())
        if uf.same(c - 1, d - 1):
            blocks[c - 1] += 1
            blocks[d - 1] += 1
    ans = [0] * n
    for i in range(n):
        ans[i] = uf.size(i) - friends[i] - blocks[i] - 1
    print(*ans)      

if __name__ == '__main__':
  main()

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

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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N;i+=2){
        int sum = 0;
        for (int j = 1; j <= i;j+=2){
            if(i % j == 0){
                sum++;
            }
        }
        if(sum == 8){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

  int ans = 0;
  for (int i = a; i <= b; i++) {
    if (c % i == 0) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3112
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	vector<int> A(N); rep(i, 0, N) {
		cin >> A[i];
	}
	A.insert(A.end(), all(A));
	unordered_map<int, int> prev;
	vector<int> B(N);
	rep(i, 0, 2 * N) {
		if (prev.count(A[i])) {
			if (prev[A[i]] >= N)continue;
			B[prev[A[i]]] = i - prev[A[i]] + 1;
		}
		prev[A[i]] = i;
	}

	dump(B);
	vector<int> C;
	int x = 0;
	unordered_set<int> vis;
	int a = 0;
	rep(i, 0, N) {
		vis.insert(x);
		int nx = x + B[x];
		nx %= N;
		a += B[x];
		C.push_back(a);
		if (vis.count(nx))break;
		x = nx;
	}
	dump(C);
	K *= N;
	K %= C.back();
	C.insert(C.begin(), 0);
	dump(C);
	rrep(i, 0, C.size()) {
		if (K - C[i] >= 0) {
			dump(C[i]);
			unordered_set<int> st;
			stack<int> stack;
			rep(k, C[i], K) {
				if (st.count(A[k % N])) {
					while (stack.top() != A[k % N]) {
						st.erase(stack.top());
						stack.pop();
					}
					st.erase(stack.top());
					stack.pop();
				}
				else {
					st.insert(A[k % N]);
					stack.push(A[k % N]);
				}
			}

			vector<int> ans;
			while (stack.size()) { ans.push_back(stack.top()); stack.pop(); }
			if (ans.size()) {
				reverse(all(ans));
				cout << ans[0]; rep(i, 1, ans.size()) { cout << " " << ans[i]; } cout << endl;
			}
			break;
		}
	}


	return 0;
}

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

typedef long long ll;
typedef pair<int, pair<int, int>> piii;
//loop
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//STL
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

//const
#define MOD 1000000007 //10^9+7:合同式の法

//acronym
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素

const int INF = 1e9;

void Main()
{
    int N; cin >> N;
    vector<string> S(N);
    REP(i, N) { cin >> S[i]; }
    vector<int> C(4, 0);
    REP(i, N)
    {
        if (S[i] == "AC") C[0]++;
        if (S[i] == "WA") C[1]++;
        if (S[i] == "TLE") C[2]++;
        if (S[i] == "RE") C[3]++;
    }
    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 6288
na, nb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min_a = min_b = 10**9
for i in range(na):
    min_a = min(min_a, a[i])
for i in range(nb):
    min_b = min(min_b, b[i])
ans = min_a + min_b
for i in range(m):
    x, y, c = map(int, input().split())
    x -= 1
    y -= 1
    ans = min(ans, a[x] + b[y] - c)
print(ans)


Measured memory_bytes: 25108
#include<iostream>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N >= 1 && N < 105) {
		cout << 0 << endl;
	}
	else if (N >= 105 && N < 135) {
		cout << 1 << endl;
	}
	else if (N >= 135 && N < 165) {
		cout << 2 << endl;
	}
	else if (N >= 165 && N < 189) {
		cout << 3 << endl;
	}
	else if (N >= 189 && N < 195) {
		cout << 4 << endl;
	}
	else if (N >= 195 && N <= 200) {
		cout << 5 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 101
using namespace std;

int main(){
  int n, w,h, s,t;
  int x,y;
  int data[N][N];

  while( cin>>n && n ){

    cin>>w>>h;
    for( int i=0;i<N;i++ )
      for( int j=0;j<N;j++ )
	data[i][j] = 0;

    for( int i=0;i<n;i++ ){
      cin >> x >> y;
      data[y][x] = 1;
    }
    cin >> s >> t;


    int max=-1;
    for( int i=0;i<=h;i++ ){
      for( int j=0;j<=w;j++ ){

	int n=0;
	for( int k=0;k<s && k+j<=w;k++ )
	  for( int l=0;l<t && l+i<=h;l++ )
	    n += data[i+l][j+k];
	if( max<n )
	  max=n;
      }
    }

    cout << max << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>

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


int main() {
    int a, b; cin >> a >> b;
    if (a <= 5){
        cout << 0 << endl;
    }else if (a < 13){
        cout << b/2 << endl;
    }else {
        cout << b << endl;
    }
}

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

int main()
{
    int n, i, a, x = 0;
    cin >> n;
    for(i = 1; i <= n; i++)
    {
        cin >> a;
        if(a != i)
            x++;
    }

    cout << (x <= 2? "YES" : "NO");

}


Measured memory_bytes: 3636
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n;
    std::cin >> n;
    Vector<Int> a(n), b(n + 1, 0);
    for (auto& x : a) std::cin >> x;
    a.insert(a.begin(), 0);

    Vector<Int> ans;
    for (Int i = n; i >= 1; --i) {
        Int s = 0;
        for (Int j = 2; i * j <= n; ++j) {
            s += b[i * j];
        }
        if (s % 2 != a[i]) {
            ans.push_back(i);
            b[i] = 1;
        }
    }

    std::cout << ans.size() << std::endl;
    for (auto x : ans) std::cout << x << ' ';
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 7396
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		String s = scan.nextLine();
		int n = s.length();

		boolean[] list0 = new boolean[n];
		boolean[] list1 = new boolean[n];
		int x  = 0;
		int xx = 1;

		for(int i = 1; i <= n; i++) {

			int y = (int) s.charAt(i - 1) - 48;

			if(i % 2 != 0) {

				list0[i - 1] = XOR(x, y);
				list1[i - 1] = XOR(xx, y);

			}else {

				list0[i - 1] = XOR(xx, y);
				list1[i - 1] = XOR(x, y);
			}
		}

		int ans0 = 0;
		int ans1 = 0;

		for(int i = 0; i < n; i++) {

			if(list0[i]) {
				ans0++;
			}
			if(list1[i]) {
				ans1++;
			}

		}

		System.out.println(Math.min(n - ans0, n - ans1));



	}

	public static boolean XOR(int x, int y) {

		if(x == y) {
			return true;
		}

		return false;
	}

}

Measured memory_bytes: 27860
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int N,A,i;
    int sum;
    scanf("%d%d",&N,&A);
 
    for(i=0;i<=20;i++){
        sum = 500*i;
        if(N <= sum + A && N >= sum){
            printf("Yes\n");
            exit(0);
        }
    }
    printf("No\n");
 
    return 0;
 
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	int c = a * b;
	if (c % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}

Measured memory_bytes: 256
import itertools
s=input()

li=list(itertools.permutations(["dream","erase","dreamer","eraser"]))

for i in li:
    t=s
    for j in range(4):
        t=t.replace(i[j],"")
    else:
        if t=="":
            print("YES")
            exit()

print("NO")

Measured memory_bytes: 3188
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    int m = *max_element(l.begin(), l.end());
    if (m < accumulate(l.begin(), l.end(), 0) - m) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int x[1000], y[1000];

int dis(int x1, int y1, int x2, int y2) {
  return (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
}
int last[1000];

int main() {
  int T;
  cin >> T;
  while(T--) {
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> g[N];
    int nx, ny; cin >> nx >> ny;
    priority_queue<pii,vector<pii>,greater<pii> > Q;
    REP(i,N) {
      cin >> x[i] >> y[i];
      REP(j,i) {
        if (dis(x[i],y[i],x[j],y[j]) <= 50*50) {
          g[i].push_back(j);
          g[j].push_back(i);
        }
      }
      last[i] = -INF;
      if (dis(x[i], y[i], nx, ny) <= 10*10) {
        last[i] = X;
        Q.push(pii(X,i));
      }
    }
    int ans = 0;
    int cnt = 0;
    bool f = 1;
    while(!Q.empty()) {
      pii p = Q.top(); Q.pop();
      int now = p.first;
      int id = p.second;
      ans = now;
      if (cnt++ > 10000) {
        f = 0;
        break;
      }
      FOR(it, g[id]) {
        if (now - last[*it] > Y) {
          last[*it] = now+X;
          Q.push(pii(now+X,*it));
        }
      }
    }
    if (f) cout << ans << endl;
    else cout << "You're always welcome!" << endl;
  }
}

Measured memory_bytes: 1060
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    int ans = 0;
    for(int i=0;i<n;i++){
      int count = 0;
      String s1 = s.substring(0,i+1);
      String s2 = s.substring(i+1,n);
      for(char c='a';c<='z';c++){
        if(s1.contains(String.valueOf(c)) && s2.contains(String.valueOf(c))){
          count++;
        }
      }
      ans = Math.max(ans,count);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll x,cost;
};
int main() {

	string s;
	char c[200002]={};
	ll cs=0,fc=1,fs=-1;
	ll q;
	cin>>s;
	cin>>q;
	rep(i,q){
		int t;
		cin>>t;
		if(t==1){
			if(fc==1&&fs==-1){
				fc=-1;
				fs=1;
			}else{
				fs=-1;
				fc=1;
			}
		}else{
			int f;
			char d;
			cin>>f>>d;
			if(f==1&&fc==1){
				c[cs]=d;
				cs++;
			}else if(f==1&&fs==1)s+=d;
			else if(f==2&&fc==-1){
				c[cs]=d;
				cs++;
			}else s+=d;
		}
	}
	if(fs==1){
		rrep(i,s.size())cout<<s[i];
		rep(i,cs)cout<<c[i];
		cout<<endl;
	}else{
		rrep(i,cs)cout<<c[i];
		cout<<s<<endl;
	}
	return 0;
}


Measured memory_bytes: 1028