akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var a = cin.nextInt();
            var b = cin.nextInt();
            
            Console.WriteLine(b % a == 0? a+b:b-a);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    s += sc.next();
    int a = Integer.parseInt(s);
    double d = Math.sqrt(a);
    String ds = Double.toString(d);
    int dotindex = ds.indexOf(".");

    if (ds.substring(dotindex + 1).replaceAll("0", "").isEmpty()) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }
}

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

template <typename T>
struct graph {
	
	struct edge {
		int from, to;
		T cost;
	};
	
	vector<edge> edges;
	vector<vector<int>> g;
	int n;
	
	graph(int n) : n(n) {
		g.resize(n);
	}
	
	virtual void add(int from, int to, T cost) = 0;
};

template <typename T>
struct undirected_graph : graph<T> {
	using graph<T>::edges;
	using graph<T>::g;
	using graph<T>::n;
	
	undirected_graph(int n) : graph<T>(n) {
		
	}
	
	void add(int from, int to, T cost = 1) {
		assert(0 <= from && from < n && 0 <= to && to < n);
		g[from].emplace_back(edges.size());
		g[to].emplace_back(edges.size());
		edges.push_back({from, to, cost});
	}
};

int main() {
	int n, m;
	cin >> n >> m;
	undirected_graph<int> g(n);
	for (int i = 0; i < m; i++) {
		int from, to;
		cin >> from >> to;
		from--;
		to--;
		g.add(from, to);
	}
	int q;
	cin >> q;
	int v[q], d[q], c[q];
	for (int i = 0; i < q; i++) {
		cin >> v[i] >> d[i] >> c[i];
		v[i]--;
	}
	reverse(v, v + q);
	reverse(d, d + q);
	reverse(c, c + q);
	int dp[n][11];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			dp[i][j] = -1;
		}
	}
	for (int i = 0; i < q; i++) {
		queue<pair<int, int>> puni;
		puni.emplace(make_pair(v[i], d[i]));
		while (!puni.empty()) {
			int x = puni.front().first;
			int dist = puni.front().second;
			puni.pop();
			if (dist < 0 || 0 <= dp[x][dist]) {
				continue;
			}
			dp[x][dist] = c[i];
			puni.emplace(make_pair(x, dist - 1));
			for (int id : g.g[x]) {
				auto &e = g.edges[id];
				int to = e.from ^ e.to ^ x;
				puni.emplace(make_pair(to, dist - 1));
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << max(0, dp[i][0]) << endl;
	}
	return 0;
}

Measured memory_bytes: 16940
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>> n;
	vector<tuple<string,int, int>> asp;
	for(int i=0;i<n;i++){
		string s;
		int p;
		cin>>s>>p;
		asp.emplace_back(s, 100-p, i+1 );
	}
	
	sort(begin(asp),end(asp));
	for(int i=0;i<n;i++){
		cout<< get<2>(asp[i]) <<endl;
	}
}

Measured memory_bytes: 3612
N = int(input())
mod = 10 ** 9 + 7
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N+1)]


def ng(a: int, b: int, c: int):
    return (a == 1 and b == 2 and c == 3)


# 初期状態の直近3文字はTTTであると見なして良い
dp[0][0][0][0] = 1
for i in range(N):
    for a in range(4):
        for b in range(4):
            for c in range(4):
                for d in range(4):
                    # 3文字パターン
                    if (ng(b, c, d) or ng(c, b, d) or ng(b, d, c)):
                        continue
                    # 4文字パターン
                    if ng(a, c, d) or ng(a, b, d):
                        continue
                    # NGパターンがなければ遷移先に足す
                    dp[i+1][b][c][d] = (dp[i][a][b][c] + dp[i+1][b][c][d]) % mod


ans = 0
for a in range(4):
    for b in range(4):
        for c in range(4):
            ans += dp[N][a][b][c] % mod


print(ans % mod)

Measured memory_bytes: 3316
from collections import Counter
N = int(input())
arr = []
arr_max = []
for i in range(N):
    arr.append(input())
dic = Counter(arr)
inverse = [(value, key) for key, value in dic.items()]
max_s = max(inverse)[0]
for key,value in dic.items():
    if value == max_s: 
        arr_max.append(key)
    else: continue
for j in sorted(arr_max): print (j)

Measured memory_bytes: 49228
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MAX = 1000001;
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() {
  ll n,a,b,c,d,e;
  cin>>n>>a>>b>>c>>d>>e;
  ll mi=min({a,b,c,d,e});
  ll ans;
  if(n%mi==0){
    ans=n/mi+4;
    cout<<ans<<endl;
    return 0;
  }
  ans=n/mi+5;
  cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
 
    int k;
    cin >> k;
 
    long long size = s.size();
 
    s = s + ' ';
    vector<int> cnt(size, 0);
 
    bool start=false;
    bool end=false;
 
    int tmp = -1;
 
    long long sum = 0;
 
    bool flag=true;
    int cnt_start=1;
    int cnt_end=0;
 
     if(s.size() == 1){
        sum = k / 2;
        cout << sum << endl;
        return 0;
    }
 
    for(int i=0; i < size-1; i++){
        if(s.at(i) != s.at(i+1)){
            break;
        }
        if(i == size-2){
            sum = ((size) * k) / 2;
            cout << sum << endl;
            return 0;
        }
    }
 
    for(int i=1; i < size; i++){
        if(s.at(0) == s.at(i)){
            cnt_start++;
        }
        else{
            break;
        }
    }
 
    for(int i=size-1; i > 0; i--){
        if(s.at(0) == s.at(i)){
            cnt_end++;
        }
        else{
            break;
        }
    }
 
    for(int j=0; j < size-1; j++){
        if(s.at(j) != s.at(j+1)){
            start = false;
        }
        else if(s.at(j) == s.at(j+1) && tmp <= j){
            start = true;
        }
 
 
        for(int i=j; i < s.size(); i++){
            if(s.at(j) == s.at(i) && start == true){
                cnt.at(j)++;
                end = true;
  //            cout << cnt.at(j) << endl;
            }
            else if(s.at(j) != s.at(i)  && end == true){
                start = false;
                end = false;
                tmp = i;
                cnt.at(j) = cnt.at(j) / 2;
            }
        }
    }
 
    for(int c: cnt){
//        cout << c << endl;
        sum += c;
    }
 
    if(size == 1){
        sum = k*size / 2; 
    }
    else{
        sum = k * sum;
        if((cnt_start + cnt_end) % 2 == 0 && cnt_start % 2 != 0 && cnt_end % 2 != 0){
           sum += (k-1);
//        cout << count << endl;
        }
    }
 
 
    cout << sum << endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double mn,mx;
struct num{int A,B;}a[1000009];
bool cmp1(const num&a,const num&b){return a.A<b.A;}
bool cmp2(const num&a,const num&b){return a.B<b.B;}
int main(){
	int n; scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].A,&a[i].B);
	sort(a+1,a+n+1,cmp1); mn=(a[(n+1)/2].A+a[(n+2)/2].A)/2.;
	sort(a+1,a+n+1,cmp2); mx=(a[(n+1)/2].B+a[(n+2)/2].B)/2.;
	if(n&1) printf("%d",(int)(mx-mn+1));
	else printf("%d",(int)(2*(mx-mn+0.5)));
	return 0;
}

Measured memory_bytes: 5324
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    return (b?gcd(a%b,b):a);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,x,a;
    cin>>n>>x>>a;
    ll res=abs(x-a);
    for(int i=1;i<n;i++){
	ll a; cin>>a;
	res=gcd(res,abs(x-a));
    }
    cout<<res<<endl;
}




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

int main() {
 int A;
 int B;
 cin >> A >> B;
  
 int ans = 0;
 for(int i=0; i<B-A+1; i++) {
  int f = (int)((A+i) / 10000);
  int s = (int)((A+i) / 1000 - f * 10);
  int t = (int)((A+i) / 100 - f * 100 - s * 10);
  int fo = (int)((A+i) / 10 - f * 1000 - s * 100 - t * 10);
  int fi = (int)((A+i) - f * 10000 - s * 1000 - t * 100 - fo * 10);
   
  if(f == fi && s == fo) {
   ans++; 
  }
 }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define w while
#define loop(i,l,r) for(int i=l;i<r;i++)
#define ci cin>>
#define co cout<<
#define ll long long
using namespace std;
int main()
 {  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
        int n,k;
       cin>>n>>k;
         int a[n];
         int dp[n];
       loop(i,0,n){
         ci a[i];
         dp[i]=INT_MAX;
       }
       //if(k>n){
         //cout<<"0";
          //    }
      // else {
      dp[0]=0;
      loop(i,0,n){
            loop(j,i+1,i+k+1){
                 if(j<n)
              dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
           }
   //}
 }
  co dp[n-1];
}


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

constexpr int OrderMax = 10;
constexpr int num753[3] = { 3, 5, 7 };

int64_t N;

bool check(int64_t a)
{
	bool check3 = false;
	bool check5 = false;
	bool check7 = false;

	for (; a > 0; a /= 10)
	{
		int b = a % 10;
		if (b == 3)
		{
			check3 = true;
		}
		if (b == 5)
		{
			check5 = true;
		}
		if (b == 7)
		{
			check7 = true;
		}

		if (check3 && check5 && check7)
		{
			return true;
		}
	}

	return false;
}

int Count(int64_t cont)
{
	int count = 0;

	for (int i = 0; i < 3; ++i)
	{
		int64_t b = cont * 10 + num753[i];
		if (b <= N)
		{
			if (check(b))
			{
				++count;
			}
			count += Count(b);
		}
	}

	return count;
}

int main()
{
	cin >> N;

	cout << Count(0) << endl;

	return 0;
}

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

int main() {

    int x,a,b;

    cin >> x >> a >> b;

    a = max(x-a,a-x);

    b = max(b-x,x-b);

    if(a<b){
        cout << 'A' << endl;
    }
    else{
        cout << 'B' << endl;
    }

    return 0;
}

Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 1000000
#define T 6
int n,k;
struct Permutation
{
	int seq[MAXN+5];
	Permutation operator * (Permutation B)
	{
		static Permutation ret;
		for(int i=1;i<=n;i++)
			ret.seq[i]=seq[B.seq[i]];
		return ret;
	}
	Permutation Inv()
	{
		static Permutation ret;
		for(int i=1;i<=n;i++)
			ret.seq[seq[i]]=i;
		return ret;
	}
	void Init()
	{
		for(int i=1;i<=n;i++)
			seq[i]=i;
	}
	void Print()
	{
		for(int i=1;i<=n;i++)
			if(i==1)
				printf("%d",seq[i]);
			else
				printf(" %d",seq[i]);
	}
};
Permutation PowMod(Permutation a,int b)
{
	static Permutation ret;
	ret.Init();
	while(b)
	{
		if(b&1)
			ret=ret*a;
		a=a*a;
		b>>=1;
	}
	return ret;
}
Permutation p,q,ans,ans2,pre,tmp,unit;
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&p.seq[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&q.seq[i]);
	
	unit=q*p.Inv()*q.Inv()*p;
	ans=PowMod(unit,(k-1)/T);
	
	k=k-(k-1)/T*T;
	ans2.Init();
	if(k==1)		ans2=p;
	else if(k==2)	ans2=q;
	else
	{
		ans2=q,pre=p;
		for(int i=3;i<=k;i++)
		{
			tmp=ans2;
			ans2=ans2*pre.Inv();
			pre=tmp;
		}
	}
	ans=ans*ans2*ans.Inv();
	ans.Print();
	printf("\n");
	return 0;
}

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

//変数色々
string s;             //入力文字列
int x, y;             //最終到達目標
vector<int>dx, dy;    //x,y軸方向に動ける距離（正負は不明）
bool dir_is_X = true; //現在の入力文字"F"はx軸方向に進むものか

int origin;              //原点の位置（配列のindexは、負の値を取れないため）
vector<vector<bool>> dpX;//1次元目:過去の移動回数,　2次元目：現在存在可能な位置（X座標において）
vector<vector<bool>> dpY;//上記同


//入力レベルの内容
void input() {
	cin >> s;
	s += "T";
	cin >> x >> y;
	origin = s.size();

	//Tが出る前に存在するFの個数を数える。
	int step = 0;//直近の"F"の連続した個数
	for (char c : s) {
		if (c == 'F') {
			step++;
		}
		else {
			if (dir_is_X) {
				dx.push_back(step);
			}
			else {
				dy.push_back(step);
			}
			dir_is_X = !dir_is_X;
			step = 0;
		}
	}
}


//実際に解くところ
void solve() {
	//初期設定
	for (int t = 0; t < origin + 1; t++) {
		dpX.push_back(vector<bool>(origin * 2 + 1));
		dpY.push_back(vector<bool>(origin * 2 + 1));
	}

	//初期位置設定
	dpX[1][origin + dx[0]] = true;//最初はX軸正の方向に進むので、先に進めておきます
	dpY[0][origin] = true;

	//過去の移動回数がtのときに、次の移動で行けるところをtrueにする
	for (int t = 1; t < dx.size(); t++) {
		for (int pos = 0; pos < origin * 2 + 1; pos++) {
			if (dpX[t][pos]) {
				dpX[t + 1][pos - dx[t]] = true;
				dpX[t + 1][pos + dx[t]] = true;
			}
		}
	}
	//Y座標も同じ
	for (int t = 0; t < dy.size(); t++) {
		for (int pos = 0; pos < origin * 2 + 1; pos++) {
			if (dpY[t][pos]) {
				dpY[t + 1][pos - dy[t]] = true;
				dpY[t + 1][pos + dy[t]] = true;
			}
		}
	}
}


//出力レベルの内容
void output() {
	if (dpX[dx.size()][origin + x] && dpY[dy.size()][origin + y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

//入出力
int main() {

	input();
	solve();
	output();

	return 0;
}


Measured memory_bytes: 32440
X, Y, Z, K = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
z_list = list(map(int, input().split()))

x_list = sorted(x_list, reverse=True)
y_list = sorted(y_list, reverse=True)
z_list = sorted(z_list, reverse=True)

cand = []

import itertools
def add_cand(list1, list2, list3):
  sum2 = []
  for a, b in itertools.product(list1, list2):
    sum2.append(a+b)
  for apb in sorted(sum2, reverse=True)[:K]:
    for c in list3:
      cand.append(apb + c)
      
add_cand(x_list, y_list, z_list)

for v in sorted(cand, reverse=True)[:K]:
  print(v)

Measured memory_bytes: 210504
import math

def get_distance(x1, y1, x2, y2):
    d = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
    return d

a, b, h, m = list(map(int, input().split()))

point_h = [
    a * math.cos(math.radians((90 - 30*h)-m/2.0)),
    a * math.sin(math.radians((90 - 30*h)-m/2.0))
]

point_m = [
    b * math.cos(math.radians(90 - 6*m)),
    b * math.sin(math.radians(90 - 6*m))
]

print(get_distance(point_h[0], point_h[1], point_m[0], point_m[1]))

Measured memory_bytes: 9564
#include <iostream>
#include <queue>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <set>
#include <stack>
#include <map>
#include <tuple>
#include <cmath>

using namespace std;
typedef long long ll;

ll a[101];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] == a[j] || a[j] == a[k])continue;
				if (a[i] + a[j] <= a[k])continue;
				ans += 1;
			}
		}
	}
	cout << ans << '\n';


}

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

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

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

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

ll dp[61];

int main(){
    int N; cin >> N;
    ll ans = 0;
    REP( i, N ){
        ll a; cin >> a;
        REP( i, 61 ){
            if( a & ( (ll)1 << i ) ){
                dp[i]++;
            }
        }
        ans += a % MOD * ( N - 1 ) % MOD;
        ans %= MOD;
    }

    REP( i, 61 ){
        if( dp[i] >= 2 ){
            if( dp[i] % 2 == 0 ){
                ans -= ( ( (ll)2 << i ) % MOD * ( dp[i] - 1 ) % MOD * dp[i] / 2 % MOD ) % MOD;
            }else{
                ans -= ( ( (ll)2 << i ) % MOD * ( dp[i] - 1 ) / 2 % MOD * dp[i] % MOD ) % MOD;
            }
        }
        ans %= MOD;
        if( ans < 0 ) ans += MOD;
    }

    cout << ans << endl;
}

/*

*/

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int h,w,i,j,fh=0;
    char s[60][60];
    scanf("%d %d",&h,&w);
    getchar();
    for(i=0;i<h;i++)
    {
        for(j=0;j<w;j++)
        {
            scanf("%c",&s[i][j]);
        }
        if(j==w)
            getchar();
    }
    for(i=0;i<h;i++)
        for(j=0;j<w;j++)
    {
        if(s[i][j]=='#')
        {
            if(s[i-1][j]!='#'&&s[i+1][j]!='#'&&s[i][j-1]!='#'&&s[i][j+1]!='#')
            {
                fh=1;break;
            }
        }
    }
    if(fh==1)
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int M=2e5+5;
const int P=1e9+7;

int n,C[M];
long long dp[M][2];
long long Sum[M];

void Solve(){
	dp[1][0]=1;Sum[C[1]]++;
	for(int i=2;i<=n;i++){
		if(C[i]==C[i-1]){dp[i][0]=dp[i-1][0],dp[i][1]=dp[i-1][1];continue;}
		(dp[i][1]+=dp[i-1][0]+dp[i-1][1])%=P;
		(dp[i][0]+=Sum[C[i]])%=P;
		(Sum[C[i]]+=dp[i][1])%=P;
	}
	printf("%lld\n",(dp[n][0]+dp[n][1])%P);
}

int main(){
	scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%d",&C[i]);
	Solve();
	return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main()
{
	int x=0,d,i=0;
	while(scanf("%d",&d)!=EOF){
	for(i=d;i<=600-d;i=i+d){
		x=(i*i*d)+x;
		}
	printf("%d\n",x);
	x=0;
	}
	return 0;
}

Measured memory_bytes: 596
#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( a )        (a).begin(), (a).end()             


int main( void ) {
	int n; cin >> n;
	deque<int> a;

	int key, size = 0;
	string com;
	REP( i, n ) {
		cin >> com;
		if( com == "insert" ) {
			cin >> key;
			a.push_front( key );
			size++;
		} else if( com == "delete" ) {
			cin >> key;
			auto ite = find( ALL( a ), key );
			if( ite != a.end() ) {
				a.erase( ite );
				size--;
			}
		} else if( com == "deleteFirst" ) {
			a.pop_front();
			size--;
		} else {
			a.pop_back();
			size--;
		}
	}

	REP( i, size - 1 ) cout << a[i] << " ";
	cout << a[size - 1] << endl;
}


Measured memory_bytes: 7048
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

struct line { int C; int S; int F; };

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  
  vector<line> lines(N);
  rep(i, N - 1) {
    int c, s, f;
    cin >> c >> s >> f;
    lines[i] = {c, s, f};
  }
  
  rep(i, N - 1) {
    // sim(lines, i);  
    int cost = 0;
    for(int j = i; j < N - 1; j ++) {
      if(cost <= lines[j].S) {
        cost = lines[j].S;
      } else if(cost % lines[j].F != 0) {
        //lower bound        
        cost = (cost / lines[j].F + 1) * lines[j].F;
      }
      cost += lines[j].C;
    }
    
    fin(cost);
  }
  
  fin(0);
  
  
}

Measured memory_bytes: 256
// DOG FACTS featuring DOGS, why aren't you reading this code RIGHT NOW
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(a);i--)
typedef long long ll;


int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    ll res = 0;
    rep(mask, 0, (1 << (n - 1))) {
        ll cur = 0;
        rep(i, 0, n) {
            cur = cur * 10 + s[i] - '0';
            if (mask & (1 << i)) {
                res += cur;
                cur = 0;
            }
        }
        res += cur;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int N;
    cin >> N;
    N %= 10;
    if(N == 3) {
        cout << "bon" << endl;
    } else if(N == 0 || N == 1 || N == 6 || N == 8) {
        cout << "pon" << endl;
    } else {
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3652
N, M = map(int, input().split())
edges = [[] for _ in range(N)]

for _ in range(M):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

def isBipartite():
    sign = [-1] * N
    sign[0] = 0
    st = [0]
    while st:
        now = st.pop()
        p = sign[now]

        for to in edges[now]:
            if sign[to] == -1:
                st.append(to)
                sign[to] = (p + 1) % 2
                continue
            if sign[to] != (p + 1) % 2:
                return -1

    return sum(sign)

s = isBipartite()

if s == -1:
    print(N * (N - 1) // 2 - M)
else:
    print(s * (N - s) - M)


Measured memory_bytes: 22064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define repi(i, x) \
	for (auto i = (x).begin(), i##_fin = (x).end(); i != i##_fin; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int, int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long, long long> P;
typedef vector<P> VP;
template <class T>
inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return 1;
	}
	return 0;
}
const long long INFLL = 1LL << 60;
const int INF         = 1 << 30;
const double PI       = acos(-1);
ll mod                = 1e9 + 7;
int main() {
	int n;
	string s;
	ll ans = 1LL;
	cin >> n >> s;
	map<char, int> dis;
	rep(i, s.size()) { dis[s[i]]++; }
	repi(itr, dis) { ans *= (1+itr->S);
		ans %= mod;
	}
	ans--;
	ans += mod;
	ans %= mod;
	cout << ans << endl;
}

Measured memory_bytes: 3760
# 最大でも3Nしか頂点には回らない
import sys
from collections import deque
input = sys.stdin.readline
n, m = map(int, input().split())

edges = [[] for i in range(n)]
for i in range(m):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    edges[u].append(v)

dist = [[False]*3 for i in range(n)]
cnt = [[0]*3 for i in range(n)]
s, t = map(int, input().split())
s -= 1
t -= 1
q = deque()
# now, dist(mod3), cnt
q.append((s, 0, 0))
while q:
    now, d, c = q.popleft()
    if dist[now][d] and cnt[now][d] <= c:
        continue
    dist[now][d] = True
    cnt[now][d] = c
    next_d = (d+1)%3
    next_c = c+1
    for to in edges[now]:
        if not dist[to][next_d] or cnt[to][next_d] > c:
            q.append((to, next_d,next_c))
if dist[t][0]:
    print(cnt[t][0]//3)
else:
    print(-1)

Measured memory_bytes: 78956
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdio>
#include<vector>
using namespace std;

int main(){
    string str;
    getline(cin,str);
    string str2;
    int ans=0;
    while(1){
       cin>>str2; 
       if(str2=="END_OF_TEXT"){
           break;
       }
        for(int i=0;i<str2.size();i++){
            if(str2[i]>='A'&&str2[i]<='Z'){
                str2[i]+='a'-'A';
            }
        }
       //int pos=str2.find(str);
       if(str==str2){
           ans++;
       }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3212
#include<cstdio>
#include<map>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<set>

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

using namespace std;

int main(){
	int a,n;cin>>n;
	vector<int> v;
	REP(i,n){
		cin>>a;
		v.push_back(a);
	}
	int ans=1,next=0;
	REP(i,n){
		if(v[next]==2){
			cout<<ans<<endl;
			return 0;
		}
		next = v[next]-1;
		ans++;
	}
	cout << "-1" << endl;
	return 0;
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   while (true) {
      int h, w;
      cin >> h >> w;
      if (h == 0 && w == 0)
         break;
      rep(i, h) {
         rep(j, w) {
            if ((i + j) % 2)
               cout << '.';
            else
               cout << '#';
         }
         cout << endl;
      }
      cout << endl;
   }
   return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <fstream>

#include <cmath>
#include <string>

#include <algorithm>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

double prob[3005];
double dp[30005][7015];

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

	int n;
	cin >> n;
	for (int i = 1; i < n+1; i++) cin >> prob[i];

	for (int i = 0; i < 3005; i++) {
		for (int j = 0; j < 7005; j++) dp[i][j] = 0;
	}

	dp[0][3005] = 1;

	for (int i = 1; i < n+1; i++) {
		for (int j = -3002; j < 3002; j++) {
			dp[i][3005+j] = dp[i-1][3005+j+1] * (1 - prob[i]) + dp[i-1][3005+j-1] * prob[i];
		}
	}

	/*
	for (int i = 0; i < n+1; i++) {
		for (int j = 3000; j < 3010; j++) {
			cout << dp[i][j] << "\t";
		}
		cout << endl;
	}
	*/

	double total = 0;
	for (int i = 3006; i < 3006+n+1; i++) {
		total += dp[n][i];
	}
	cout << fixed << setprecision(20) << total << endl;

	return 0;
}


Measured memory_bytes: 166272
#include <iostream>
#include <algorithm>
#include <map>
#include <iomanip>

using namespace std;

long comb(long n, long k) {
    if (n < k || k < 0) return 0;
    if (n == k || k == 0) return 1;
    return comb(n-1, k-1) * n / k;
}

int main() {
    long n, a, b;
    cin >> n >> a >> b;
    map<long, long, greater<long>> m;
    for (long i=0; i<n; i++) {
        long v;
        cin >> v;
        m[v]++;
    }
    bool first = true;
    long sum=0, orga = a;
    for (auto p:m) {
        if (a <= p.second) {
            if (first) {
                long lim = min(b, p.second),
                     ans = 0;
                for (long i=a; i<=lim; i++) ans += comb(p.second, i);
                cout << p.first << '\n' << ans << '\n';
            } else {
                sum += p.first * a;
                cout << setprecision(10) 
                     << (double)sum / orga << '\n'
                     << comb(p.second, a) << '\n';
            }
            return 0;
        }
        if (first) first = false;
        a -= p.second;
        b -= p.second;
        sum += p.first * p.second;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

perm = list(itertools.permutations([i for i in range(1, N+1)], N))

for i, p in enumerate(perm):

    if p == P:
        a = i + 1
    if p == Q:
        b = i + 1

print(abs(a - b))




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

int main() {
  int n, t, a;
  cin >> n >> t >> a;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  //aとt-h[i]*0.006が近いもの。添え字のずれ注意
  //h[i]=(t-a)/0.006
  double ondosa = 10000.0;
  int kouho;
  for (int i = 0; i < n; i++) {
    double sa = abs(a - (t - 0.006 * h[i]));
    if (sa < ondosa) {
      ondosa = sa;
      kouho = i + 1;
    }
  }
  cout << kouho;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			new Main().exec(sc);
		}
	}

	public void exec(Scanner sc) {
		int n = sc.nextInt();
		int r = sc.nextInt();
		int rating = 0;
		if (n >= 10) {
			rating = r;
		} else {
			rating = r + (100 * (10 - n));
		}
		System.out.println(rating);
	}
}


Measured memory_bytes: 22356
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <cmath>
#include <set>
#include <stack>
#include <queue>
#include <numeric>
#include <deque>
#include <cstring>
#include <iterator>
#include <map>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <complex>
#include <bitset>
#include <chrono>
#include <random>
#include <assert.h>

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define eb emplace_back
#define el '\n'
typedef  long long  ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;


const int mod=1000000007;
//const int mod=998244353;


int main()
{   ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll t,n,m,k,q,x,a,b,c,d,y,l,r;
    cin >> n >> k;
    vb v(10);
    for(int i=0; i<k; i++){
        cin >> a;
        v[a]=true;
    }
    for(int i=n,p; ; i++){
        p=i;
        bool cond=true;
        while(p){
            if(v[p%10])cond=false;
            p/=10;
        }
        if(cond){cout << i << el; break;}
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
//#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;

class UnionFind {
public:
	vector<int>data;
	UnionFind(int size) :data(size, -1) {};
	bool unionset(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				swap(x, y);
			}
			data[x] += data[y];
			data[y] = x;
		}
		return x != y;
	}
	bool findset(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int x,int y) {
	int tmp,r;
	if (x < y) {
		tmp = x;
		x = y;
		y = tmp;
	}
	r = x % y;
	while (r != 0) {
		x = y;
		y = r;
		r = x % y;
	}
	return y;
}

int main(void) {
	int N,a,res;
	vector<int>vec;
	cin >> N;
	for (int i = 0; i < N;i++) {
		cin >> a;
		vec.push_back(a);
	}
	res = gcd(vec[0], vec[1]);
	for (int i = 1; i < N - 1;i++) {
		res = gcd(res,vec[i + 1]);
	}
	cout << res << endl;
}

Measured memory_bytes: 892
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include<functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <stack>
#include <deque>

#define LL long long
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"
#define REP(e,v) for(auto e:v)
#define rep(i, a, n) for(LL i = a; i < n;i++)

using namespace std;

struct edge {
    LL to;
    LL cost;
};

/*
 LL V;

 cin >> V;

 vector<edge> G[V];

 rep(i,0,V){
 	 LL e;

 	 cin >> e;

 	 rep(j,0,e){
 	 	 LL to,cost;
 	 	 cin >> to >> cost;

 	 	 G[j].insert(new edge(to,cost));
 	 }
 }

 */

void dijkstra(LL s,LL V,vector<edge> G[],LL d[]) {
    priority_queue<pLL, vector<pLL>, greater<pLL> > que;
    fill(d, d+V, INT_MAX);
    d[s] = 0;
    que.push(pLL(0, s));

    while (!que.empty()) {
        pLL p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(pLL(d[e.to], e.to));
            }
        }
    }
}


int inp(){
	int x;
	scanf("%d",&x);
	return x;
}
LL linp(){
	LL x;
	scanf("%lld",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}


LL gcd(LL i,LL j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;

}

LL A(){
	LL K,A,B;

	cin >> K >> A >> B;

	rep(i,A,B+1){
		if(i % K == 0) {
			printf("OK");
			return 0;
		}
	}

	printf("NG");

	return 0;
}

LL B(){

	LL X;

	cin >> X;

	LL count = 0;
	LL money = 100;

	while(money < X){
		money *= 1.01;
		count++;

	}

	outp(count);

	return 0;
}

LL C(){
	return 0;
}

LL D(){
	return 0;
}


signed main() {
	//A();
	B();
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

vector<int> Zalgo(string &S) {
  int N = S.size();
  vector<int> Z(N, 0);

  Z[0] = N;
  int i = 1, j = 0;
  while (i < N) {
    while (i + j < N && S[j] == S[i + j]) j++;
    Z[i] = j;

    if (j == 0) {
      i++;
      continue;
    }
    int k = 1;
    while (k < j && k + Z[k] < j) {
      Z[i + k] = Z[k];
      k++;
    }
    i += k;
    j -= k;
  }
  int ret = 0;
  for (int i = 1; i < N; ++i) {
    ret = max(ret, Z[i]);
  }
  return Z;
}

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;

  int answer = 0;
  rep(i, N - 1) {
    string T = S.substr(i, N - i);
    auto lcp = Zalgo(T);
    for (int j = 0; j < (N - i); ++j) {
      int l = min(lcp[j], j);
      answer = max(answer, l);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3712
S = input().strip()
#-----

i=len(S)
while i >= 0:

    if S[(i-7):i] == "dreamer":
        i=i-7
    elif S[(i-6):i] == "eraser":
        i=i-6
    elif S[(i-5):i] == "dream" or S[(i-5):i] == "erase":
        i=i-5
    else:
        print("NO")
        break

    if i == 0:
        print("YES")
        break


Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(10**6)

INF=10**9
N,M=map(int,input().split())

def dfs(u,d1):
  pos_list[u]=d1
  for v,d2 in graph[u]:
    if pos_list[v]==-INF:
      dfs(v,d1+d2)
    elif pos_list[v]!=d1+d2:
      print("No")
      sys.exit(0)      
  return

graph=[]
for i in range(N+1):
  graph.append([])
for i in range(M):
  L,R,D=map(int,input().split())
  graph[L].append((R,D))
  graph[R].append((L,-D))
#print(graph)

pos_list=[-INF]*(N+1)
for i in range(1,N+1):
  if pos_list[i]!=-INF:
    continue
  dfs(i,0)
          
#print(pos_list[1:])
print("Yes")

Measured memory_bytes: 128944
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val) { //usage: int dp[10][10]; Fill(dp,INF);
    std::fill((T *) array, (T *) (array + N), val);
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};*/

//-----Template---------
LL a, b;

int main() {
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin >> a >> b;
    if(a>=0 && b>=0){
        if(a<=b){
            cout<<b-a<<endl;
        }else{
            int res = INF;
            chmin(res,abs(abs(a)-abs(b))+2);
            chmin(res,abs(b+a)+1);
            cout<<res<<endl;
        }
    }else if(a<0 && b<0){
        if(a<=b){
            cout<<b-a<<endl;
        }else{
            cout<<abs(a-b)+2<<endl;
        }
    }else{
        if(a<=b){
            int res=INF;
            chmin(res,b-a);
            chmin(res,abs(abs(b)-abs(a))+1);
            cout<<res<<endl;
        }else{
            cout<<abs(abs(b)-abs(a))+1<<endl;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A.sort()
max_A = A[-1]
arr = [0] * (max_A + 1)

for val in A:
    arr[val] += 1
    if arr[val] == 1:
        for j in range(2*val, max_A + 1, val):
            arr[j] += 2

print(arr.count(1))

Measured memory_bytes: 32296
#include<cstdio>
#include<algorithm>
using namespace std;

typedef long long ll;

int main(){
	int n;
	char s[100001];
	ll ans = 0;
	scanf("%d %s",&n,s);
	ll J = 0, O = 0, I = 0;
	int Iall = 0;
	ll usi = 0, uma = 0, dugong = 0;
	for(int i=0;i<n;i++) if(s[i]=='I') Iall++;
	for(int i=0;i<n;i++){
		if(s[i-1]=='O') ans += J * (Iall - I);
		if(s[i-1]=='J') J++;
		else if(s[i-1]=='O') O++;
		else if(s[i-1]=='I') I++;
	}
	J = O = I = 0;
	for(int i=0;i<n;i++){
		if(s[i]=='O') usi += Iall - I;
		else if(s[i]=='I') I++;
	}
	J = O = I = 0;
	for(int i=0;i<n;i++){
		if(s[i]=='J') J++;
		else if(s[i]=='O') uma += J;
	}
	J = O = I = 0;
	for(int i=0;i<n;i++){
		if(s[i]=='J') J++;
		else if(s[i]=='I') I++;
		dugong = max(dugong,J*(Iall-I));
	}
	usi = max(usi,uma);
	dugong = max(dugong,usi);
	ans += dugong;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2832
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.rbegin(),v.rend()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define ff first
#define sc second
typedef long long ll;
using namespace std;
bool sortByVal(const pair<string, int> &a,
               const pair<string, int> &b)
{
    return (a.second < b.second);
}
int main()
{
    int n,i,j,val=0,cost=0,ans=0;
    cin>>n;
    map<string,int>m,mm;
    string s;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
    }
    vector<pair<int,string> >v;
    for(auto [l,r]: m)
    {
        v.pb({r,l});
    }
    sort(all(v));
    set<string>ss;
    i=0;
    while(v[0].ff==v[i].ff)
    {
       // see(v[i].sc)
        mm[v[i].sc]++;
        //ss.insert(v[i].sc);
        i++;
    }
    for(auto [l,r]:mm)
    {
        cout<<l<<endl;
    }
    return 0;
}


Measured memory_bytes: 42224
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 10
#define MAX_D 30
#define swap(a, b) { int t = a; a = b; b = t; }

int l[MAX_N];
char ex[MAX_D][MAX_N - 1];
int n, m;
int a;
int d;

bool
calc_lots()
{
	int i, j;

	for (i = 0; i < n; ++i)
		l[i] = i + 1;

	for (i = 0; i < d; ++i)
	{
		for (j = 0; j < n - 1; ++j)
		{
			if (ex[i][j] == '1')
				swap(l[j], l[j + 1]);
		}
	}

	if (l[a - 1] == m)
		return true;

	return false;
}

bool
test_lots(int c, int r)
{
	if ((c - 1 < 0 || ex[r][c - 1] == '0') && ex[r][c] == '0' && (n - 1 <= c + 1 || ex[r][c + 1] == '0'))
	{
		ex[r][c] = '1';
		if (calc_lots())
			return true;

		ex[r][c] = '0';
	}

	return false;
}

void
solve()
{
	int c, r;

	if (calc_lots())
	{
		printf("0\n");
		return;
	}

	for (r = 0; r < d; ++r)
	{
		for (c = 0; c < n - 1; ++c)
		{
			if (test_lots(c, r))
			{
				printf("%d %d\n", r + 1, c + 1);
				return;
			}
		}
	}

	printf("1\n");
}

int
main(int argc, char **argv)
{
	char c;
	int i, j;

	while (true)
	{
		scanf("%d", &n);
		if (n == 0)
			break;

		scanf("%d", &m);
		scanf("%d", &a);
		scanf("%d\n", &d);

		for (i = 0; i < d; ++i)
		{
			for (j = 0; j < n - 1; ++j)
				scanf("%c", &ex[i][j]);

			scanf("%c", &c);
			if (c != '\n')
				goto l_end;
		}

		solve();
	}

l_end:
	return 0;
}

Measured memory_bytes: 612
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long long lint;
typedef pair<lint, lint> P;

bool lessPair(const P& l, const P& r){return l.second < r.second;}
bool lessindex(const P& l, const P& r){return l.first < r.first;}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint Q; cin >> Q;

    vector<lint> A(N);

    REP(i, N) {
      lint a; cin >> a; A[i] = a;
    }

    vector<P> X(Q);
    vector<lint> res(Q);

    REP(i, Q) {
      lint a; cin >> a; X[i] = P(i, a);
    }

    sort(X.begin(), X.end(), lessPair);

    lint tmp = 0;

    FOR(i, N/2, N) {
      tmp += A[i];
    }

    lint i1,i2;
    if(N%2 == 1) {
    i1 = 0;
    i2 = N-2 -(N-3)/2;
    }
    else {
    i1 = 1;
    i2 = N-2 -(N-4)/2;
    }


    REP(i, Q) {
      lint x = X[i].second;
      while(x > (A[i1] + A[i2])/2 && i1 != i2) {
        tmp -= A[i2];
        tmp += A[i1];
        i1 += 2;
        i2 += 1;
      }
      //      cout << "x " << x << "\n";
      //      cout << i1 << " " << i2 << "\n";
      
      res[X[i].first] = tmp;
    }

    REP(i, Q) {
      cout << res[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  vector<vector<int>> a(3, vector<int>(3));
  rep (i, 3) rep(j, 3) cin >> a[i][j];
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i, n) cin >> b[i];
  vector<vector<bool>> checked(3, vector<bool>(3));
  rep(x, n) {
    rep (i, 3) rep(j, 3) {
      if(a[i][j] == b[x]) checked[i][j] = true;
    }
  }
  bool ok = false;
  rep (i, 3) {
    bool tmp = true;
    rep(j, 3) {
      if(!checked[i][j]) tmp = false;
    }
    if(tmp) ok = true;
  }
  rep (i, 3) {
    bool tmp = true;
    rep(j, 3) {
      if(!checked[j][i]) tmp = false;
    }
    if(tmp) ok = true;
  }
  bool tmp = true;
  rep(i, 3){
    if(!checked[i][i]) tmp = false;
  }
  if(tmp) ok = true;
  tmp = true;
  rep(i, 3){
    if(!checked[i][2 - i]) tmp = false;
  }
  if(tmp) ok = true;
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256