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

using namespace std;

const int maxn = 1e5 + 3;
const int mod = 998244353;

int n, m[4];
vector <int> adj[4][maxn];
void read()
{
    cin >> n;
    for (int i = 1; i <= 3; i++)
    {
        cin >> m[i];
        for (int j = 1; j <= m[i]; j++)
        {
            int a, b;
            cin >> a >> b;

            adj[i][a].push_back(b);
            adj[i][b].push_back(a);
        }
    }
}

long long add(long long a, long long b)
{
    a += b;
    if (a >= mod)
        a -= mod;

    return a;
}

long long st[maxn*2];
int gr[4][maxn];
map <int, long long> mp[4];
void solve()
{
    st[0] = 1;
    for (int i = 1; i <= 2 * n; i++)
        st[i] = st[i-1] * 1000000000 % mod;

    for (int i = 1; i <= 3; i++)
    {
        mp[i][0] = add(mp[i][0], st[n*2]);
        for (int j = n-1; j >= 1; j--)
        {
            set <int> s;
            for (auto k: adj[i][j])
                if (k > j)
                s.insert(gr[i][k]);

            while (s.find(gr[i][j]) != s.end())
                gr[i][j]++;

            mp[i][gr[i][j]] = add(mp[i][gr[i][j]], st[j*2]);
        }
    }

    int p = sqrt(max({m[1], m[2], m[3]})) * 2;
    long long ans = 0;
    for (int i = 0; i <= p; i++)
        if (mp[1].count(i))
        for (int j = 0; j <= p; j++)
        if (mp[2].count(j))
            ans = add(ans, mp[1][i] * mp[2][j] % mod * mp[3][i^j] % mod);

    cout << ans << endl;
}

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

    read();
    solve();
}


Measured memory_bytes: 20736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



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

	ll ans = 0;
	for (i = 1; i <= n; i++) {
		ans += max(0LL, (n/i)*(i - k));
		ans += max(0LL, n%i - k + 1);
	}
	for (i = 1; i <= n; i++) {
		if (0 % i >= k)ans--;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	long long a, b, k;
	cin >> a >> b >> k;
	long long take = min(k, a);
	a -= take, k -= take;
	cout << a << ' ' << max(0LL, b-k) << endl;
}


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

bool KBjudge(string x) {
	
  string x_ = x;
  reverse(x.begin(), x.end());
  return (x_ == x);
}


int main(){
  
  
  string S;
  cin >> S;
  int N = S.size();
  

  if (KBjudge(S.substr(0, S.size()))){
    if (KBjudge(S.substr(0, (N - 1)/2))){
      if (KBjudge(S.substr((N + 3)/2 - 1, N - (N + 3)/2 + 2))){
        
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())

if abs(x) >= d:
  t = abs(x)//d
  if k >= t:
    if (k - t) % 2 ==0:
      print(abs(x) % d)
    else:
      print(d - (abs(x) % d))
  else:
    print(abs(x) - k*d)
else:
  if k % 2 == 0:
    print(abs(x))
  else:
    print(abs(abs(x) - d))


Measured memory_bytes: 9104
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(N)]
count=0
for j in range(N):
	if sum((A[j][k])*(B[k]) for k in range(M))+C>0:
		count=count+1
print(count)

Measured memory_bytes: 3064
N = int(input())
A = [0] * N
B = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b
A = sorted(A)
B = sorted(B)
res = 0
if N % 2 == 1:
    l = A[int(N/2)]
    r = B[int(N/2)]
    res = r - l + 1
else:
    l = A[int(N/2) - 1] + A[int(N/2)]
    r = B[int(N/2) - 1] + B[int(N/2)]
    res = r - l + 1
print(res)

Measured memory_bytes: 26956
# include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll sum(0);
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        else sum += i;
    }
    cout << sum << "\n";
    return 0;
}

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

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	int N,p[10],mx=0,ans=0;
    cin>>N;
    REP(i,N){
        cin>>p[i];
        ans+=p[i];
        if(mx<p[i]){
            mx=p[i];
        }
    }
    ans-=mx/2;
    cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;string s;int main(){cin>>s;string q=s;reverse(q.begin(),q.end());for(int i=0;i<s.size();i++){if(q[i]=='b')q[i]='d';else if(q[i]=='d')q[i]='b';else if(q[i]=='p')q[i]='q';else if(q[i]=='q')q[i]='p';}if(s==q)printf("Yes\n"); else printf("No\n");} 

Measured memory_bytes: 512
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
ll gcd(ll a, ll b)
{
	if (b == 0)return a;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region LCM
ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int k; cin >> k;
	if (k == 7 || k == 1)
	{
		cout << 1 << endl;
		return 0;
	}
	int d = 7;
	int r = 0;
	int res = 0;
	do
	{
		if (d == 0 || res > 1e8)
		{
			cout << -1 << endl;
			return 0;
		}
		r += d % k;
		++res;
		r %= k;
		d *= 10;
		d %= k;
	} while (r != 0);
	cout << res << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>

typedef long long ll;

using namespace std;

int main() {
    ll H;
    cin >> H;
    ll count = 0;
    ll sum = 0;
    for (ll h = H; h > 0; h /= 2) {
        sum += pow(2, count);
        count++;
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define per(i,r,l) for (int i=r,i##end=l;i>=i##end;--i)
#define rep0(i,r) for (int i=0,i##end=r;i<i##end;++i)
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pb push_back
using namespace std;
const int N=1e6+6;
int a[N]; ll s[N];
int main(){
    int n,m,v,p; scanf("%d%d%d%d",&n,&m,&v,&p);
    rep(i,1,n) scanf("%d",&a[i]);
    sort(a+1,a+1+n),reverse(a+1,a+1+n);
    rep(i,1,n) s[i]=s[i-1]+a[i];
    int ans=p;
    rep(i,p+1,n){
        int v0=v-(p-1)-(n-i+1);
        if (a[p]>a[i]+m) break;
        else if (v0<0) ++ans;
        else if ((ll)(m+a[i])*(i-p)-(s[i-1]-s[p-1])>=(ll)v0*m) ++ans;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

int func(LL n) {
	int res = 0;

	while (n > 0) {
		n /= 10;
		res++;
	}

	return res;
}

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

	LL n;
	cin >> n;

	int ans = func(n);

	for (LL i = 1; i * i <= n; i++) {
		if (n % i != 0) {
			continue;
		}

		int num = max(func(i), func(n / i));
		ans = min(ans, num);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
H,W = map(int, input().split())
s = [None] * H
for i in range(H):
  s[i] = input()

dx = [1,0,-1,0]
dy = [0,1,0,-1]

for i in range(H):
  for j in range(W):
    if s[i][j] == '#':
      count = 0
      for k in range(4):
        x = j + dx[k]
        y = i + dy[k]
        if 0 <= x < W and 0 <= y < H:
          if s[y][x] == '#':
            count += 1
       
      if count == 0:
        print('No')
        exit()
print('Yes')

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

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define INF LLONG_MAX
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef unsigned long long lu;
const ll mod = 998244353;
ll power(ll a, ll b)
{
    ll ans = 1;
    while (b > 0)
    {
        if (b % 2 == 1)
        {
            ans = (ans * a) % mod;
        }
        a = (a * a) % mod;
        b = b / 2;
    }
    return ans;
}
vll fac(200005, -1);
ll fact(ll n)
{
    if (fac[n] != -1)
    {
        return fac[n];
    }
    else if (n == 0)
    {
        return 1;
    }
    return fac[n] = (n * fact(n - 1)) % mod;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m, k, ans = 0;
    cin >> n >> m >> k;
    for (int i = 0; i <= k; i++)
    {
        ll tp = (fact(n - 1) * power((fact(n - 1 - i) * fact(i)) % mod, mod - 2)) % mod;
        ans = (ans + ((m * tp) % mod * power(m - 1, n - i - 1)) % mod) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7932
#include <bits/stdc++.h>
#include <iostream>
#include <cassert>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
#include <array>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#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--)
//xにはvectorなどのコンテナ
#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 MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	int n;
	std::string s;
	std::cin >> n;
	std::cin >> s;
	int l[3*100000+10];
	int r[3*100000+10];
	int a[3*100000+10];
	int lnum=0,rnum=0;
	for ( int i = 0 ; i < n ; i++ ) {
		if(s[i]=='W'){
			lnum ++;
		}
		if(s[n-1-i]=='E'){
			rnum ++;
		}
		l[i] = lnum;
		r[n-1-i] = rnum;
	}
	for ( int i = 0 ; i < n ; i++ ) {
		a[i] = l[i] + r[i];
		// std::cout << i<< " : "<<a[i] << " l:"<<l[i] << " r:"<<r[i] << std::endl;
	}
	ll min = INF;
	int index = 0;
	for ( int i = 0 ; i < n ; i++ ) {
		if (min > a[i]){
			min = a[i];
		}
	}
	std::cout << min-1 << std::endl;

	return 0;
}


Measured memory_bytes: 4228
import math
from math import gcd,pi,sqrt
INF = float("inf")

import sys
sys.setrecursionlimit(10**6)
import itertools
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    a = list(s_input())
    b = list(s_input())
    c = list(s_input())

    t = "a"

    while True:
        if t == "a":
            if len(a) == 0:
                print("A")
                exit()

            t = a.pop(0)
        elif t == "b":
            if len(b) == 0:
                print("B")
                exit()

            t = b.pop(0)
        else:
            if len(c) == 0:
                print("C")
                exit()
            t = c.pop(0)


if __name__=="__main__":
    main()


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

int main(){
  
  int D;
  int T;
  int S;
  
  cin >> D >> T >> S;
  
  if( D <= S*T ){
    cout << "Yes" << endl;
  }
  
  else if ( D > S*T ){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3616
N = int(input())

d_count = {}
for i in range(N):
    S = str(input())
    d_count.setdefault(S, 0)
    d_count[S] = d_count[S] + 1

max = 0
maxlist = []
for S in d_count:
    if(max < d_count[S] ):
        max = d_count[S]
        maxlist = [S]
    if(max == d_count[S]):
        maxlist.append(S)

maxlist_set = list(set(maxlist))
maxlist_set.sort()
for a in maxlist_set:
    print(a)

Measured memory_bytes: 43996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <bits/stdc++.h>
#include <stack>
#include <map>
#include <ctype.h>

using namespace std;

#define loop(i,n) for (i = 0; i < n; ++i) 
#define loop2(i,k,n) for (i = k; i <= n; ++i) 
#define loopb(i,k,n) for (i = k; i >= n; --i)
#define remove_space(x) x.erase(remove(x.begin(), x.end(), ' '), x.end())
typedef long long ll;

int main(){

    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    string s;
    cin >> s;


    int count = 0;
    for(int i=0; i<n; i++){
    	if(s[i] == s[i+1]){
    		continue;
    	}

    	else{
    		count++;
    	}
    }

    cout << count;
	return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null) {

			int[] a = new int[4];
			int[] b = new int[4];
			int hit = 0;
			int blow = 0;
			
			String[] as = line.split(" ");
			for (int i = 0; i < a.length; i++) {
				a[i] = Integer.parseInt(as[i]);
			}

			String[] bs = br.readLine().split(" ");			
			for (int i = 0; i < b.length; i++) {
				b[i] = Integer.parseInt(bs[i]);
			}

			// hit
			for (int i = 0; i < a.length; i++) {
				if (a[i] == b[i]) {
					hit++;
					a[i] = -1;// 例外値
				}
			}

			// blow
			for (int i = 0; i < a.length; i++) {
				if (a[i] == -1)
					continue;
				for (int j = 0; j < b.length; j++) {
					if (b[j] == -1)
						continue;
					if (a[i] == b[j]) {
						blow++;
						b[j] = -1;
					}
				}
			}

			//
			System.out.println(hit + " " + blow);
		}
	}
}

Measured memory_bytes: 16904
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define N (100005)

using namespace std;

int dis[N],vis[N],n;
queue<int> Q;

il void spfa(){
  for (RG int i=1;i<n;++i) dis[i]=i,vis[i]=1,Q.push(i);
  dis[0]=n,vis[0]=1,Q.push(0);
  while (!Q.empty()){
    RG int x=Q.front(),v; Q.pop();
    if (dis[v=x*10%n]>dis[x]){
      dis[v]=dis[x];
      if (!vis[v]) vis[v]=1,Q.push(v);
    }
    if (dis[v=(x+1)%n]>dis[x]+1){
      dis[v]=dis[x]+1;
      if (!vis[v]) vis[v]=1,Q.push(v);
    }
    vis[x]=0;
  }
  return;
}

int main(){
  cin>>n,spfa();
  cout<<dis[0];
  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	string s,t;
	cin>>s>>t;
	ll n=s.length();
	ll m=t.length();
	ll dp[n+1][m+1];
	ll i,j;
	for(i=0;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(i==0 || j==0)
			{
				dp[i][j]=0;
			}
			else{
				if(s[i-1]==t[j-1])
				{
					dp[i][j]=dp[i-1][j-1]+1;
				}
				else{
					dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
				}
			}
		}
	}
	string r;
	i=n;
	j=m;
	while(i>0 && j>0)
	{
		if(s[i-1]==t[j-1])
		{
			r.push_back(s[i-1]);
			i--;
			j--;
		}
		else{
			if(dp[i-1][j]>dp[i][j-1])
			{
				i--;
			}
			else{
				j--;
			}
		}
	}
	reverse(r.begin(),r.end());
	cout<<r;
}

Measured memory_bytes: 73956
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <set>
#include <sstream>
#include <bitset>
#include <stack>
#include <cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

typedef long long ll;

using namespace std;

int main() {
    
    
    ll n,m;
    
    cin >> n >> m;
    
    if((n==1)&&(m==1)){
        cout << 1 << endl;
    }else if((n==1)||(m==1)){
        cout << n*m-2 << endl;
    }else{
        cout << n*m-((n-1)+(m-1))*2 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
n=gets.to_i
b=gets.split.map(&:to_i)
cnt=0
a=[]
(n-1).times do |i|
  if b[i]-b[i+1]>=0 then
    cnt+=1
  elsif
    a.push(cnt)
    cnt = 0
  end
end
print a.push(cnt).max


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

int main(){
    int n;
    cin >> n;
    vector<string> a(n);
    int i, j, k;
    for(i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int ans = 1;
    string s = a.at(0);
    for(i = 0; i < n; i++){
        if(a.at(i) != s){
            ans++;
            s = a.at(i);
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e18;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

ll solve(ll left, ll right, function<ll(ll)> pred) {
	while (right - left > 1) {
		ll middle = left + right;
		middle /= 2;
		if (pred(middle)) {
			right = middle;
		}
		else {
			left = middle;
		}
	}
	return right;
}


int main() {
	ll k;
	cin >> k;
	vector<ll> as(k);
	rep(i, k) cin >> as[i];
	auto lower = solve(0, 1e15, [&](ll middle) {
		rep(i, k) {
			middle = middle / as[i] * as[i];
		}
		return middle >= 2;
	});
	auto upper = solve(0, 1e15, [&](ll middle) {
		rep(i, k) {
			middle = middle / as[i] * as[i];
		}
		return middle > 2;
		});
	upper--;
	if (lower > upper) {
		cout << -1 << endl;
	}
	else {
		cout << lower << " " << upper << endl;
	}
	return 0;
}


Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

ll solve(){
  ll N; cin>>N;
  ll cumu[N+1]; cumu[0] = 0;
  REP(i,N){
    ll a; cin >> a;
    cumu[i+1] = cumu[i] + a;
  }
  sort(cumu,cumu+N+1);
  ll ans = 0;
  ll buf = 0;
  ll c = pow(10,9);
  REP(i,N+1){
    if(cumu[i]!=c){
      ans += buf*(buf-1)/2;
      c = cumu[i];
      buf = 1;
    }else{
      ++buf;
    }
  }
  ans += buf*(buf-1)/2;
  return ans;
}

int main(){
  cout << solve()<<"\n";
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
 
// GNU C Compiler
//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
 
/*
--------------------------------------------
 
	type
 
--------------------------------------------
*/
using LL = long long;
using ULL = unsigned long long;
//using pair<T1, T2> = p12;
 
/*
--------------------------------------------
 
	container
 
--------------------------------------------
*/
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
 
/*
--------------------------------------------
 
	repetition
 
--------------------------------------------
*/
#define MAX(a,b) (a>b)?a:b
#define MIN(a,b) (a>b)?b:a
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)
 
//algorithm
//#define SORT(c) sort((c).begin(),(c).end())
 
/*
--------------------------------------------
 
	constant
 
--------------------------------------------
*/
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
/*
 
	Optimizer
 
*/
//#pragma GCC optimize("Ofast")


/*
 
	Utility Algorithm
 
*/
template <typename T>
void swapAlgorithm(T& a, T& b) {
    T tmp = a;
    a = b;
    b = tmp;
}

LL euclideanAlgorithm(LL a, LL b) {
    LL a_tmp = a;
    LL b_tmp = b;

    if (a_tmp > b_tmp) {
        swapAlgorithm<LL>(a_tmp, b_tmp);
    }

    LL r = a_tmp % b_tmp;
    while (r != 0) {
        a_tmp = b_tmp;
        b_tmp = r;
        r = a_tmp % b_tmp;
    }
    return b_tmp;    
}

LL getLCM(LL a, LL b) {
    return (a * b)/(euclideanAlgorithm(a, b));
}

/*
  Code
*/

double eauclidDistance(pair<double, double>& x1, pair<double, double>& x2) {
  return sqrt((x1.first - x2.first) * (x1.first - x2.first) + (x1.second - x2.second) * (x1.second - x2.second));
}

int main(int argc, char const *argv[])
{
  int N;
  cin >> N;

  vector<int> d(N);
  REP(N) cin >> d[i];

  sort(d.begin(), d.end());

  if(d.size() % 2 == 1) {
    cout << 0 << endl;
  }
  else {
    cout << (d[N/2]-d[N/2-1]) << endl;
  }

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
  for (int &u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

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

  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  REP(i,N) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 23552
import java.util.Scanner;
 
public class Main {
    public static void main(String... args) {
        Scanner sc = new Scanner(System.in);
        while(true) {
        int n = sc.nextInt();
        int x = sc.nextInt();
            if(n == 0 && x == 0) break;
        int s = 0;
        for(int i = 1; i <= n; i++) {
            for(int j = i + 1; j <= n; j++) {
                for(int k = j + 1; k <= n; k++) {
                    if(i + j + k == x) s++;
                }
            }
        }
        System.out.println(s);
        }
    }
}


Measured memory_bytes: 26688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

  if (a1 * t1 + a2 * t2 == b1 * t1 + b2 * t2) {
    cout << "infinity" << endl;
    return 0;
  }
  if (a1 > b1) {
    swap(a1, b1);
    swap(a2, b2);
  }
  if (a1 < b1 && a1 * t1 + a2 * t2 < b1 * t1 + b2 * t2) {
    cout << 0 << endl;
    return 0;
  }
  else {
    ll g1 = b1 * t1 - a1 * t1;
    ll g2 = a2 * t2 - b2 * t2;
    ll ans = g1 / (g2 - g1) * 2 + 1;
    if (g1 % (g2 - g1) == 0) ans--;
    cout << ans << endl;
  }



  
  return 0;
}

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

int main() {
  long int N;
  cin >> N;
  int x = sqrt(N);
  for(int i = x;i>0;i--){
    if((N%i)==0){
         cout << i+(N/i)-2 << endl;
    break;    
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b, c, i = 0, sum = 0, buffer = 0, flag = 0;

    scanf("%d %d %d", &a, &b, &c);

    if(c <= a){
        printf("%d\n", c);
        return 0;
    }/*else if(60 % (a+b) == 0){
        printf("-1\n");
        return 0;
    }*/
    while(1){
        buffer = (i++)*60;
        if((buffer + c) % (a+b) <= a){
            printf("%d\n", buffer + c);
            return 0;
        }
        if(i==1000000){
            printf("-1\n");
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 596
d,g = map(int, input().split())
P = []
C = []
PC = []
for i in range(d):
    p,c = map(int, input().split())
    P.append(p)
    C.append(c)
    PC.append((p,c))
    
P_sum = sum(P)
dp = [0 for i in range(P_sum + 1)]
for i,j in enumerate(PC):
    for k in range(P_sum,  -1, -1):
        for l in range(1,j[0]+1):
            if l + k <= P_sum:
                if l == j[0]:
                    cc = 100 * (i + 1)* l + j[1]
                else:
                    cc = 100 * (i + 1) * l
                dp[l + k] = max(dp[l + k ], dp[k] + cc)
                
for i,j in enumerate(dp):
    if j >= g:
        print(i)
        break

Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			// input
			int n = in.nextInt();
			int k = in.nextInt();

			// solve
			long count = 0;

			for (int b = 1; b <= n; b++) {
				int p = n / b;
				int r = n % b;
				count += Math.max(b-k, 0)*p + Math.max(r-k+1, 0);
			}
			if (k == 0) {
				count -= n;
			}

			out.println(count);
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23508
#include "bits/stdc++.h"
using namespace std;

#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); i++ )
#define REP( i, n )		FOR( i, 0, n )
#define ALL( x )		(x).begin(), (x).end()

int main() {
	stack<int> s;
	int x, y;
	string str;
	
	while( 1 ) {
		cin >> str;
		if( cin.eof() ) break;
		if( str == "+" ) {
			x = s.top(); s.pop();
			y = s.top(); s.pop();
			s.push( x + y );
		} else if( str == "-" ) {
			x = s.top(); s.pop();
			y = s.top(); s.pop();
			s.push( y - x );
		} else if( str == "*" ) {
			x = s.top(); s.pop();
			y = s.top(); s.pop();
			s.push( x * y );
		} else {
			s.push( stoi( str ) );
		}

	}

	cout << s.top() << endl;
}


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

int main()
{
    int a,b,c,d,e,f,ans1=0,ans2=0,i,j,k,l,res1,res2,temp1;
    double diff=INT_MIN;
    cin>>a>>b>>c>>d>>e>>f;
    a*=100;
    b*=100;
    for(j=0;j<=f/b;j++)
    {
        for(i=1;i<=f/a;i++)
        {
            res1=a*i+b*j;
            if(res1>f)
                break;
            temp1=(res1*e)/100;
            for(l=0;l<=temp1/d;l++)
            {
                for(k=0;k<=temp1/c;k++)
                {
                    res2=c*k+d*l;
                    if(res1+res2>f || res2>temp1)
                        break;
                    double temp2=((100*res2)/(double)(res1+res2));
                    if(diff<temp2)
                    {
                        diff=temp2;
                        ans1=res1;
                        ans2=res2;
                    }
                }
            }
        }
    }
    cout<<ans1+ans2<<" "<<ans2<<endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return list(map(int, input().split()))

N = int(input())
C= Counter(inpl())

F = sorted([k for k, v in C.items() if v >= 4] + [0])
T = sorted([k for k, v in C.items() if v >= 2] + [0, 0])

print(max(F[-1]*F[-1], T[-1]*T[-2]))

Measured memory_bytes: 18592
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
			String[] spl = br.readLine().split(" ");
			int[] num = new int[spl.length];
			for(int i = 0;i <spl.length;i++) {
				num[i] = Integer.parseInt(spl[i]);
			}
			Arrays.sort(num);
			if(num[0] + num[1] == num[2]) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21076
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n--){
    string a,b,ans;
    cin >>a>>b;
    int as = a.size(),bs = b.size(),s,c,t=0;
    s = (as<bs)? bs:as;
    for(int i=0; i<s; i++){
      if(i<as && i<bs) c = a[as-i-1]+b[bs-i-1]-'0'*2+t;
      else if(i<as) c = a[as-i-1]-'0'+t;
      else if(i<bs) c = b[bs-i-1]-'0'+t;
      t = c/10;
      ans+=('0'+c%10);
    }
    if(t) ans+='1';
    if(ans.size()>80) cout <<"overflow";
    else for(int i=ans.size()-1; i>=0; i--) cout <<ans[i];
    cout <<endl;
  }
}

Measured memory_bytes: 1204
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
#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, t;
  cin >> s >> t;
  int cnt = 0;
  rep(i, s.size()) {
    if (s[i] != t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int n;
    cin >> n;
    vi seqO(n/2), seqE(n/2);
    rep(i, n/2){
        cin >> seqO[i];
        cin >> seqE[i];
    }

    vi cntO(100100, 0), cntE(100100, 0);

    rep(i, n/2){
        cntO[seqO[i]]++;
        cntE[seqE[i]]++;
    }

    int maxO=0, max2O=0, maxE=0, max2E=0; //一番大きいとこの番号（要素の数ではない）

    rep(i, 100001){
        if(cntO[i]>cntO[maxO]){
            max2O=maxO;
            maxO=i;
        }
        else if(cntO[i]>cntO[max2O]){
            max2O=i;
        }

        if(cntE[i]>cntE[maxE]){
            max2E=maxE;
            maxE=i;
        }
        else if(cntE[i]>cntE[max2E]){
            max2E=i;
        }
    }
    
    int ans=n;

    if(maxO!=maxE){
        ans -= cntO[maxO] + cntE[maxE];
    }else{
        ans -= max(cntO[maxO] + cntE[max2E], cntO[max2O] + cntE[maxE]);
    }

    cout << ans << endl;

    return 0;
}

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

void call(int n){
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << i;
        } else {
            do {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                } else {
                    x /= 10;
                }
            } while (x);
        }
    }

    cout << endl;
}

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

    return 0;
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define eps 1e-10;
#define INF 0x3f3f3f3f
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn=2e5+100;

int n,a[maxn],tree[maxn];
vector<int> v;
LL ans=0;
int getid(int x) {return lower_bound(v.begin(),v.end(),x)-v.begin()+1;}
int lowbit(int x) {return x&(-x);}
void add(int x,int y) {for(int i=x;i<=n+2;i+=lowbit(i)) tree[i]+=y;}
LL getsum(int x) {
    LL ret=0;
    for(int i=x;i;i-=lowbit(i)) ret+=tree[i];
    return ret;
}

int main() {
    #ifdef ac
        freopen("in.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif // ac
    cin >> n;
    for(int i=1;i<=n;++i) cin >> a[i],v.push_back(a[i]);
    sort(v.begin(),v.end());  v.erase(unique(v.begin(),v.end()),v.end());
    for(int i=n;i;--i) {
        int id=getid(a[i]);
        ans+=getsum(id); add(id+1,1);
    }
    cout << ans << endl;
    return 0;
}

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

string T;

int main(void) {
  cin >> T;
  int ans = 0;
  for (int i=0; i<(int)T.size(); i++) {
    if (T[i] == 'D') ans++;
    else if (T[i] == 'P' && T[i+1] == 'D') ans++;
    else if (T[i] == '?') {
      ans++;
      T.replace(i,1,"D");
    }
  }
  cout << T << endl;
  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

ll MOD = 1000000007;

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

	ll n, m;
	cin >> n >> m;

	vector<bool> safe(n + 1, true);
	for (ll i = 0; i < m; i++) {
		ll a;
		cin >> a;

		safe[a] = false;
	}

	vector<ll> memo(n + 1);
	memo[0] = 1;
	for (ll i = 0; i < n; i++) {
		if (!safe[i]) {
			continue;
		}

		// 1段上がる
		if (safe[i + 1]) {
			memo[i + 1] += memo[i];
			memo[i + 1] %= MOD;
		}

		if (i + 2LL > n) {
			continue;
		}

		// 2段上がる
		if (safe[i + 2]) {
			memo[i + 2] += memo[i];
			memo[i + 2] %= MOD;
		}
	}

	cout << memo[n] << endl;
	return 0;
}


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

public class Main {

	public static void main (String[] args) {
	   InputReader in = new InputReader(System.in);
	   int n = in.readInt();
	   int y = in.readInt();
	   for(int i = 0; i<n+1; i++) {
		   for(int j = 0; j<n+1; j++) {
			   int x = (n-i-j);
			   if(x < 0)continue;
			   if(10*i + 5*j + x == y/1000) {
				   System.out.println(i+" "+j+" "+x);
				   return; 
			   }
		   }
	   }
	   System.out.println(-1 + " " + -1 + " " + -1);
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

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

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

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


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

typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl; 
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main(){
    //OJ;
    FIO;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    while(b<=a and k>0){
        b=b*2;
        k--;
    }
    while(c<=b and k>0){
        c=c*2;
        k--;
    }
    if(a<b and b<c){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
}


Measured memory_bytes: 3008
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

n = ni()
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
div_l = make_divisors(n)
if len(div_l) % 2 == 0:
    m1 = div_l[len(div_l) // 2]
    m2 = div_l[len(div_l) // 2-1]
    print(m1+m2-2)
else:
    m = div_l[len(div_l) // 2]
    print(m*2 - 2)


Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			String s = in.next();
			int r0 = 0;
			int r1 = 0;
			for (int i = 0; i < s.length(); i++) {
				char c = s.charAt(i);
				if (i % 2 == 0 ^ c == '0') {
					r0++;
				} else {
					r1++;
				}
			}
			System.out.println(Math.min(r0, r1));
		}
	}

}


Measured memory_bytes: 24672
package main

import (
	"bufio"
	"errors"
	"fmt"
	"math"
	"os"
	"strconv"
)

type Int64Map map[ // Int64Map は、map[Int64][Int64]に便利メソッドを追加します.
int64]int64

func lib_AbsInt64(value int64) int64 {
	return int64(math.Abs(float64(value)))
}
func lib_MinInt64(values ...int64) (min int64, err error) {
	if len(values) == 0 {
		return 0, errors.New("empty slice is given")
	}
	min = values[0]
	for _, value := range values {
		if min > value {
			min = value
		}
	}
	return
}
func lib_NewInt64Map() Int64Map {
	return map[int64]int64{}
}
func (m Int64Map) ChMin(key, value int64, values ...int64) (replaced bool, valueAlreadyExist bool) {
	min, _ := lib_MinInt64(append(values, value)...)
	if v, ok := m[key]; ok {
		if v > min {
			m[key] = min
			return true, true
		} else {
			return false, true
		}
	}
	m[key] = min
	return true, false
}
func (m Int64Map) MustGet(key int64) int64 {
	v, ok := m[key]
	if !ok {
		panic(fmt.Sprintf("ivnalid key is specfied in Int64Map: %v", key))
	}
	return v
}
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var N int64
	scanner.Scan()
	N, _ = strconv.ParseInt(scanner.Text(), 10, 64)
	h := make([]int64, N)
	for i := int64(0); i < N; i++ {
		scanner.Scan()
		h[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}
	fmt.Println(solve(N, h))
}
func solve(N int64, h []int64) int64 {
	m := lib_NewInt64Map()
	m[0], m[1] = 0, lib_AbsInt64(h[1]-h[0])
	for i := int64(2); i < N; i++ {
		m.ChMin(i, m[i-1]+lib_AbsInt64(h[i-1]-h[i]), m[i-2]+lib_AbsInt64(h[i-2]-h[i]))
	}
	return m.MustGet(N - 1)
}


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

using namespace std;

int main()
{
    int H,W,K;
    cin>>H>>W>>K;
    char c[10][10];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>c[i][j];
        }
    }
    long ans=0;
    for(int bit=0;bit<(1<<H);bit++){
        char d[10][10];
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                d[i][j]='B';
            }
        }
        for(int i=0;i<H;i++){
            if(bit&(1<<i)){
                for(int j=0;j<W;j++){
                    d[i][j]='A';
                }
            }
        }
        for(int bit1=0;bit1<(1<<W);bit1++){
            char e[10][10];
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    e[i][j]='B';
                }
            }
            int C=0;
            for(int i=0;i<W;i++){
                if(bit1&(1<<i)){
                    for(int j=0;j<H;j++){
                        e[j][i]='A';
                    }
                }
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(d[i][j]=='A'){
                        continue;
                    }else if(e[i][j]=='A'){
                        continue;
                    }
                    if(c[i][j]=='#'){
                        C++;
                    }
                }
            }
            
            if(C==K){
                ans++;
            }
        }
        
    }    
    cout<<ans<<endl;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    map<ll,ll> m;
    COMinit();
    for(ll i=0; i<n; i++) m[a[i]]+=1;
    map<ll,ll> m2;
    ll all=0;
    for(auto i=m.begin(); i!=m.end(); i++){
        m2[i->first]=(i->second)*(i->second-1)/2;
        all+=(i->second)*(i->second-1)/2;
    }

    for(int i=0; i<n; i++){
        cout<<all-m2[a[i]]+((m[a[i]]-1)*(m[a[i]]-2))/2<<endl;
    }
}

Measured memory_bytes: 30976