akhauriyash/Code-Regression huggingface dataset:
=begin
－－－－－－－－－－－－－－
  n = 入力値
  num = nの奇数のみ配列
  cnt = 約数の個数
  ans[] =  奇数かつ約数が"ちょうど8個"ある整数を格納
－－－－－－－－－－－－－－
  1: 1 ~ n までを繰り返す(i)
  2: i が奇数の場合、iの約数を数える
  3: i の約数が"ちょうど8個"の場合のみ ans に代入
  4: ansの要素数を出力
=end

def cnt_divisor(num)
  cnt = 1;
  for i in 2..num do
    cnt += 1 if num % i == 0
  end
  return cnt
end

n = gets.to_i;
num = (1..n).select{|v| v.odd?};
ans = [];

num.each do |num|
  ans << num if cnt_divisor(num) == 8;
end

puts ans.size;

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    vector<int> L;
    rep(i,N){
        int tmp=0;
        cin>>tmp;
        L.push_back(tmp);
    }
    int ans =0;
    rep(i,N){
        rep(j,N){
            rep(k,N){
                if(L[i]!=L[k]&&L[i]!=L[j]&&L[j]!=L[k]&&(L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j])){
                    ans++;
                }
            }
        }
    }
    cout << ans/6 << endl;
    return 0;
}

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

/**
 * 最大公約数 
 */
ll gcd(ll numA, ll numB)
{
    return numB ? gcd(numB, numA % numB) : numA;
}

/** 
 * 最小公倍数
 */
ll lcm(ll x, ll y)
{
    return x / gcd(x, y) * y;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> nums(N);
    for(int i = 0; i < N; i++)
    {
        int A;
        cin >> A;
        nums.at(i) = A;
    }
    int prevCount = -1;
    for(int i = 0; i < N; i++)
    {
        int count = 0;
        ll num = nums.at(i);
        while (num % 2 == 0){
            count++;
            num /= 2;
        }
        if(i == 0){
            prevCount = count;
            continue;
        }
        if(prevCount != count){
            cout << 0 << endl;
            return 0;
        }
        prevCount = count;
    }
    ll lcmNum = nums.at(0);
    for(int i = 1; i < N; i++)
    {
        lcmNum = lcm(lcmNum, nums.at(i));
    }
    ll answer = 0;
    lcmNum /= 2;
    answer = (M / lcmNum + 1) / 2;
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep2(x,from,to) for(long long x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
long long n;
long long a[200006];
long long dpe[200006][2];//last ari 1
int main()
{
    cin>>n;
    rep(i,n)cin>>a[i];
    for(long long i=2;i<=n;i+=2)
    {
        if(i==2)
        {
            dpe[2][0]=a[0];
            dpe[2][1]=a[1];
        }
        else
        {
            dpe[i][0]=dpe[i-2][0]+a[i-2];
            dpe[i][1]=max(dpe[i-2][0],dpe[i-2][1])+a[i-1];
        }       
    }
    if(n%2==0)
    {
        cout<<max(dpe[n][1],dpe[n][0])<<endl;
        return 0;
    }
    for(long long i=3;i<=n;i+=2)
    {
        if(i==3)
        {
            dpe[i][0]=max(a[0],max(a[1],a[2]));

        }
        else
        {
            dpe[i][0]=max(dpe[i-1][1],dpe[i-1][0]);
            dpe[i][0]=max(dpe[i][0],dpe[i-2][0]+a[i-1]);
        }
    }
    cout<<dpe[n][0]<<endl;

    return 0;
}

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

int main(){
    int A, B, C, N, M ,K;
    int sum = 0;
    int t = 0;
    string s, s1;
    cin >> A >> B;
    if(B%A == 0) cout << A+B << endl;
    else cout << B-A << endl;
//    vector<int> X();

//    for(int i = 0; i < ; i++){}
//    for(int j = 0; j < ; j++){}

//    cout <<  << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<int> vi;

int main()
{
    int N;
    cin >> N;

    string S;
    cin >> S;

    vector<int> W(N, 0);
    vector<int> E(N, 0);

    int w = 0;
    int e = 0;
    REP (i, N)
    {
        if (S[i] == 'W') w++;
        else e++;

        W[i] = w;
        E[i] = e;
    }

    int X = 300001;
    REP (i, N)
    {
        int RE = E[N - 1] - E[i];

        X = min(X, W[i - 1] + RE);
    }

    cout << X << endl;
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int> ,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}
int main()
{
    FIO;
    //int t;
    //cin>>t;
    //while(t--)
        go();
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstring>
using namespace std;
#define MAX_N (5)
int n;
char memo[1<<25];
int sq[6][6];
int dfs(int bit){
	if(~memo[bit]) { return memo[bit];}
	int ans = (1<<25);
	
	for(int i = 0 ; i < n ; i++){
		for(int j = 0 ; j < n ; j++){
			if( bit >> (i*MAX_N+j) & 1){
				for(int s1 = 1 ; s1 <= n-i ; s1++)
					for(int s2 = 1 ; s2 <= n-j ; s2++)
						ans = min( ans , 1 + dfs( bit ^ (sq[s1][s2] << (i*MAX_N+j) ) ) );
				goto endfunction;
			}
		}
	}
	endfunction: return memo[bit] = ans;
}
int gen(int x,int y){
	int ans = 0;
	for(int i = 0 ; i < y ; i++)
		for(int j = 0 ; j < x ; j++)
			ans |= 1<< (i*MAX_N+j);
	return ans;
}
int main(){
	for(int i = 1 ; i <= 5 ; i++) for(int j = 1 ; j <= 5 ; j++) sq[i][j] = gen(j,i);
	memset(memo,-1,sizeof(memo));
	memo[0] = 0;
	
	while(cin >> n , n){
		int bit = 0 , a;
		
		for(int i = 0 ; i < n ; i++)
			for(int j = 0 ; j < n ; j++)
				cin >> a , bit |= a << (i * MAX_N + j);
		int r = dfs(bit);
		for(int i = 0 ; i < r ; i++)
			cout << "myon";
		cout << endl;
	}
}

Measured memory_bytes: 32000
def sol():
    mod=1000000007
    ans=0
    n=int(input())
    a=[int(i) for i in input().split()]
    x=[[0]*63 for i in range(n+1)]
    #l=[yy(2**i)%mod for i in range(63)]
    l=[pow(2,i,mod) for i in range(63)]

    for i in range(n):
        d=a[i]
        cnt=0
        for j in range(63):
            if d&1:
                x[i+1][cnt]=x[i][cnt]+1
            else:
                x[i+1][cnt]=x[i][cnt]
            cnt+=1
            d=d>>1

    for i in range(1,n):
        for j in range(63):
            p=x[i][j]-x[i-1][j]
            if p:
                ans+=l[j]*((n-i)-(x[-1][j]-x[i][j]))
            else:
                ans+=l[j]*(x[-1][j]-x[i][j])
            ans%=mod
    print(ans)

if __name__=="__main__":
    sol()

Measured memory_bytes: 207308
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  string S, T;
  cin >> S >> T;
  bool ans = false;
  for(int i=0; i<S.size(); ++i)
  {
    if(S==T)
    {
      ans = true;
      break;
    }
    S = S.back() + S.substr(0, S.size()-1);
  }
  if(ans)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll a, b;
    cin >> a >> b;
    if(a == 2 || b == 2){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int A = sc.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
    int B = sc.nextInt();
    int C = sc.nextInt();
    int D = sc.nextInt();
    
    while(A > 0 && C > 0){
      C -= B;
      if (C <= 0){
        System.out.println("Yes");
        return;
      }
      A -= D;
      if (A <= 0){
        System.out.println("No");
        return;
      }
    }
    
  }
}


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

int main() {
	static long long N, K, A[200000], F[200000], L = -1, R = 100000000000000000;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) cin >> F[i];
	sort(A, A + N);
	sort(F, F + N, greater<long long>());
	while (R - L > 1) {
		long long MID = (L + R) / 2;
		long long COUNT = 0;
		for (int i = 0; i < N; i++) {
			COUNT += max(0LL, A[i] - MID / F[i]);
		}
		if (COUNT <= K) R = MID;
		else L = MID;
	}
	cout << R << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    int ma = *max_element(a.begin(), a.end());
    int mi = *min_element(a.begin(), a.end());
    cout << ma - mi << endl;

    return 0;
}


Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

void print(int *x, int n) {
	for(int i=0;i<n;i++) cout<<x[i]<<" ";
	cout<<endl;
}

void solve() {
	int n, k, c;
	cin>>n>>k>>c;
	string s;
	cin>>s;
	
	int left[n], right[n];
	MSV(left, -1);
	MSV(right, -1);
	
	int day = 1;
	for(int i=0;i<n;) {
		if(s[i] == 'x') {i++;continue;}
		left[i] = day++;
		i+=(c+1);
		if(day > k) break;
	}
	
	day = k;
	for(int i=n-1;i>=0;) {
		if(s[i] == 'x') {i--;continue;}
		right[i] = day--; 
		i-=(c+1);
		if(day<=0) break;
	}
	
	for(int i=0;i<n;i++) {
		if(s[i] == 'x') continue;
		if(left[i] == right[i] && left[i] != -1) cout<<i+1<<endl;
	}
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 5316
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
using namespace std;
#define MAX_V 10240
 
// 从&#39030;点from指向&#39030;点to的&#26435;&#20540;&#20026;cost的&#36793;
typedef struct edge
{
	int to, distance, cost;
	edge(){}
	edge(int to, int distance, int cost) : to(to), distance(distance), cost(cost){}
	bool operator > (const edge & b) const
	{
		return distance != b.distance ? distance > b.distance : cost > b.cost;
	}
} P;
 
// first 最短路径，second&#39030;点&#32534;号
 
// &#22270;
vector<edge> G[MAX_V];
 
// V是&#39030;点数
int V;
bool visited[MAX_V];
 
// 求解从&#39030;点s出&#21457;到所有点的最短花&#36153;
int dijkstra(int s)
{
	int result = 0;
	priority_queue<P, vector<P>, greater<P> > que;
	memset(visited, 0, V * sizeof(bool));
	que.push(P(0, 0, 0));
 
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.to;
		if (visited[v]) continue;
		visited[v] = true;
		result += p.cost;
		for (int i = 0; i < G[v].size(); ++i)
		{
			edge e = G[v][i];
			que.push(P(G[v][i].to, p.distance + G[v][i].distance, G[v][i].cost));
		}
	}
 
	return result;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	int /*N = V,*/ M;
	while (cin >> V >> M && V)
	{
		for (int i = 0; i < V; ++i)
		{
			G[i].clear();
		}
		for (int i = 0; i < M; ++i)
		{
			int u, v, d, c;
			cin >> u >> v >> d >> c;
			--u, --v;
			G[u].push_back(edge(v, d, c));
			G[v].push_back(edge(u, d, c));
		}
 
		cout << dijkstra(0) << endl;
	}
	return 0;
}
///////////////////////////End Sub//////////////////////////////////

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

int N;
vector<double> p;
vector<vector<double>> dp;

double rec(int coin, int heads)
{
	if (coin == N)
	{
		if (heads >= (N + 1) / 2)
			return 1;
		return 0;
	}
	if (dp[coin][heads] != -1.0)
		return dp[coin][heads];
	double temp = 0;
	temp = p[coin] * rec(coin + 1, heads + 1) + (1.0 - p[coin]) * rec(coin + 1, heads);
	return dp[coin][heads] = temp;
}

int main()
{
	ios_base::sync_with_stdio(false);

	cin >> N;
	p.resize(N);
	dp.resize(N, vector<double> (N, -1.0));
	for (int i = 0; i < N; i++)
		cin >> p[i];
	double answer = rec(0, 0);
	cout << fixed << setprecision(12) << answer;

	return 0;
}

Measured memory_bytes: 74068
/*
[abc165] A - We Love Golf
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
#define ALL(c) (c).begin(), (c).end()

int K;
int A, B;

ll solve() { return B / K * K >= A; }

int main() {
    cin >> K;
    cin >> A >> B;

    cout << (solve() ? "OK" : "NG") << endl;

    return 0;
}


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

#define ll long long
#define ull unsigned long long
#define N 100005
#define mod 998244353 
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
#define prec(n) fixed<<setprecision(n)

#define mii unordered_map<int,int>
#define mll unordered_map<ll,ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define pp pop_back
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define all(c) c.begin(),c.end()
#define tr(it,c) for(it = c.begin() ; it!=c.end() ; it++)
int inf = INT_MAX ;
ll modulo(ll num,ll MOD=mod){ return ((num%MOD)+MOD)%MOD;} // for negative integer
ll power(ll b,ll e,ll MOD=mod){ll ans=1; while(e){if(e%2) ans=(ans*b)%MOD; b=(b*b)%MOD; e/=2;} return ans;}
ll inv(ll num,ll MOD=mod){ return power(modulo(num),MOD-2,MOD); }
ll gcd(ll a,ll b){ return ((b==0) ? a:gcd(b,a%b));}

int main(){
	boost;

	int n,y;
	cin>>n>>y;
	
	priority_queue<int> pq;

	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		pq.push(a);
	}

	for(int i=0;i<y;i++){
		int a = pq.top();
		pq.pop();
		a = a/2;
		pq.push(a);
	}

	ll sum = 0;
	while(pq.size()>0){
		sum = sum + pq.top();
		pq.pop();
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 892
N=int(input())
for h in range(1,3501):
  for n in range(1,3501):
    if 4*h*n-N*n-N*h!=0:
      w=(N*n*h)/(4*h*n-N*n-N*h)
      if int(w)==w and w>0:
        print(h,n,int(w))
        exit()

Measured memory_bytes: 73676
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iostream>
#include<cmath>
#include<map>
#include<set>
#include<climits>
using namespace std;
typedef vector<string>vs;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<double>vd;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll>pll;
typedef vector<ll>vl;
typedef pair<int,pii>piii;
#define rrep(i,x,n) for(int i=(x);i<(n);++i)
#define rep(i,x) rrep(i,0,(x))
#define fi first
#define se second
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define maxs(a,b) (a)=max(a,b)
#define mins(a,b) (a)=min(a,b)
///#include<sstream>
///#include<cstring>
///#include<stack>
///#include<complex>


bool flag[200000];
int prev[200000],next[200000];
int main(){
    int N,M,Q;
    scanf("%d%d%d",&N,&M,&Q);
    fill_n(flag,N,true);
    int pos=0;
    rep(i,N)prev[i]=(i+N-1)%N;
    rep(i,N)next[i]=(i+1)%N;
    while(M--){
        int a;scanf("%d",&a);
        if(a&1)rep(i,a)pos=prev[pos];
        else rep(i,a)pos=next[pos];
        flag[pos]=false;
        next[prev[pos]]=next[pos];
        prev[next[pos]]=prev[pos];
        pos=next[pos];
    }
    while(Q--){
        int q;scanf("%d",&q);
        puts((flag[q]?"1":"0"));
    }

    return 0;

}

Measured memory_bytes: 2928
#include<cstring>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<queue>
#include<bitset>
#include<cstdlib>
#include<set>
#include<unordered_map>
#define l(x) (x<<1)
#define r(x) ((x<<1)|1)
#define low(x) (x&(-x))
#define IL inline
#define reg register
#define LL long long
#define N 500010
#define MOD 998244353
#define MO 1000000007
#define INF 0x3f3f3f3f
using namespace std;

LL T,n,i,j,k,x,y,z;
LL a[N],b[N];
char c[N];

struct Data{
	LL x,y;
}d[N];

IL LL Abs(LL x){return (x<0)?-x:x;}
IL void Swap(LL &a,LL &b){a^=b^=a^=b;}
IL LL Min(LL a,LL b){return (a<b)?a:b;}
IL LL Max(LL a,LL b){return (a>b)?a:b;}
IL bool cmp(const Data a,const Data b){return a.x<b.x;}

IL LL Mi(LL x,LL y){
	LL p=x,t=1,Res=1;
	for (;t<=y;(t&y)?Res=(Res*p)%MOD:0,p=(p*p)%MOD,t<<=1);
	return Res;
}

IL LL read(){
	LL p=0,f=1;	char	c=getchar();
	while (c<48||c>57)	{if (c=='-')	f=-1;	c=getchar();}
	while (c>=48&&c<=57)	p=(p<<1)+(p<<3)+c-48,c=getchar();
	return p*f;
}

int main(){
	#ifdef __Marvolo
	freopen("zht.in","r",stdin);
	freopen("zht.out","w",stdout);
	#endif
	n=read();	T=read();
	T=T*T;
	int Ans=0;
	for (i=1;i<=n;i++){
		x=read();	y=read();
		z=x*x+y*y;
		if (z<=T)	Ans++;
	}
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
        String s[] = new String[n];
        for(int i = 0; i < n; i++){
        	s[i] = sc.next();
            if(i > 0 &&  !(s[i - 1].substring(s[i - 1].length() - 1).equals(s[i].substring(0,1)))){
            	System.out.println("No");
                return;
            }
            for(int j = 0; j < i; j++){
            	if(s[i].equals(s[j])){
                	System.out.println("No");
                    return;
                }
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 35764
import numpy as np
n = int(input())
a = np.fromstring(input(), dtype=np.int64, sep=' ')
for i in range(n):
    a[i] = a[i] - i - 1
x = int(np.median(a))
r = 0
for i in range(n):
    r += abs(a[i]-x)
print(r)

Measured memory_bytes: 31560
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#define lol(i,n) for(ll i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;

int main(){
    ll a,b,c;cin>>a>>b>>c;a++;
    cout<<(a-b)*(a-c)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back
int n;
LL a[N],d[N], e[N], x, y;
LL cnt, k, P;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] < 0) {
      cnt++;
      e[++y] = a[i];
    } else if (a[i] > 0) {
      P++;
      d[++x] = a[i];
    }
  }
  sort(d + 1, d + 1 + x);
  sort(e + 1, e + 1 + y);
  if (cnt * P >= k) { // ans <0
    LL l = -1e18, r = -1, ans = -1;
    while (l <= r) {
      LL mid = l + r >> 1;
      LL tot = 0;
      for (int i = 1; i <= n; i++) {
        if (a[i] < 0) {
          //a[i]*x<=mid
          //x>=mid/a[i]
          int pos = lower_bound(d+1,d+1+x,mid/a[i]+(mid%a[i]==0?0:1))-d;
          tot += x-pos+1;
        }
      }
      if (tot >= k)
        ans = mid, r = mid - 1;
      else
        l = mid + 1;
    }
    cout << ans << '\n';
  } else if (cnt * P + (n - P - cnt) * (P+cnt)+(n-P-cnt)*(n-P-cnt-1)/2 >= k) {
    cout << 0 << '\n';
  } else { // ans >0
    k-=cnt * P + (n - P - cnt) * (P+cnt)+(n-P-cnt)*(n-P-cnt-1)/2;
    //cout<<k<<endl;
    LL l = 1, r = 1e18, ans = 1e18;
    while (l <= r) {
      LL mid = l + r >> 1, tot = 0;
      for (int i = 1; i <= n; i++) {
        if (a[i] > 0) {
          //a[i]*x<=mid;
          //x<=mid/a[i]
          LL res = mid / a[i];
          int pos = upper_bound(d + 1, d + 1 + x, res) - d - 1;
          tot += pos;
          if(a[i]*a[i]<=mid)tot--;
        } else if(a[i]<0){
           //x*a[i]<=mid
           //x>=mid/a[i];
          LL res = mid / a[i];
          int pos = lower_bound(e + 1, e + 1 + y, res) - e;
          tot += y - pos + 1;
          if(a[i]*a[i]<=mid)tot--;
        }
        //if(mid==3 && a[i]!=0)cout<<i<<' '<<tot<<endl;
      }
     // cout<<mid<<' '<<tot<<'\n';
      if (tot/2 >= k)
        ans = mid, r = mid - 1;
      else
        l = mid + 1;
    }
    cout << ans << '\n';
  }
  return 0;
}
//87940638538504704
//448283280358331064

Measured memory_bytes: 4224
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] ary = new int[5];
        for (int i = 0; i < 5; i += 1) {
            ary[i] = sc.nextInt();
        }
        int k = sc.nextInt();

        for (int i = 0; i < 5; i += 1) {
            for (int j = i + 1; j < 5; j += 1) {
                if (ary[j] - ary[i] > k) {
                    System.out.println(":(");
                    return;
                }
            }
        }
        System.out.println("Yay!");
    }

}


Measured memory_bytes: 21716
s = input()
t = input()

res = []

for s_index in range(len(s)-len(t)+1):
    if s[s_index] in ['?', t[0]]:
        s_p = s[s_index:s_index+len(t)]
        if len([True for x in range(len(s_p)) if s_p[x] in ['?', t[x]]]) == len(t):
            res.append(s[:s_index].replace('?', 'a') + t + s[s_index+len(t):].replace('?', 'a'))

if res:
    print(sorted(res)[0])
else:
    print('UNRESTORABLE')


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (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--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{

  int x, a;
  cin >> x >> a;
  if (x < a)
    pr(0);
  else
    pr(10);
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <iomanip>
#include <sys/time.h>
#include <random>
#include <cassert>


#define fs first
#define sc second
#define endl "\n"

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef pair<int, int> P;


vector<int> get_scores(vector<int>& c, vector<vector<int>>& s, vector<int>& t, int D){
    vector<int> res;
    vector<int> las(26, -1);
    int score = 0;
    for(int i = 0; i < D; i++){
        int contest = t[i];
        int up = s[i][contest];
        int down = 0;
        las[contest] = i;
        for(int j = 0; j < 26; j++){
            down += c[j] * (i - las[j]);
        }
        score += (up - down);
        res.push_back(score);
    }
    return res;
}


int main(){
    int D;  cin >> D;
    vector<int> c(26);
    for(int i = 0; i < 26; i++) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    for(int i = 0; i < D; i++){
        for(int j = 0; j < 26; j++){
            cin >> s[i][j];
        }
    }

    vector<int> t(D);
    for(int i = 0; i < D; i++){
        cin >> t[i];
        t[i]--;
    }

    vector<int> res = get_scores(c, s, t, D);
    for(auto x: res){
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
 
int main()
{
    int A, B;
    cin >> A >> B;

    int ans = 0;
    if (13 <= A) ans = B;
    else if (6 <= A && A <= 12) ans = B / 2;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

const std::string con = "AGCT";

std::string S;
int ans;

int main()
{
  std::cin >> S;

  int cnt = 0;
  rep( i, S.size() )
  {
    if( con.find( S[i] ) != std::string::npos )
      ++cnt;
    else
      ans = std::max( ans, cnt ), cnt = 0;   
  }

  ans = std::max( ans, cnt );

  printf( "%d\n", ans );

  return 0;
}

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

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();

            Console.WriteLine(N % 2 == 0 ? N / 2 : N / 2 + 1);
            Console.ReadKey();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 11092
n,m = map(int, input().split())
ab = [[] for _ in range(n+1)]

for _ in range(m):
  a,b = map(int, input().split())
  ab[a].append(b)
  ab[b].append(a)

for i in ab[1]:
  for j in ab[i]:
    if j == n:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

Measured memory_bytes: 41620
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
using namespace std;
#define PI 3.14159265358979
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{
    int a,b,c;

    cin>>a>>b>>c;



    int mod = a%b;


    for(int i=1;i<100;i++)
    {
        int mod2 = mod *i;

        mod2 = mod2%b;
        if(mod2 == c)
        {
            cout<<"YES"<<endl;
            return 0;
        } 
    }   


cout <<"NO"<<endl;

}






Measured memory_bytes: 256
#include<iostream>
#include<bitset>
#include<algorithm>

using namespace std;

typedef long long ll;

int N, K;
ll A[5000 + 10];
bitset<5000 + 10> dpl, dpr;
int suml[5000 + 10][5000 + 10], sumr[5000 + 10][5000 + 10];
//[x, y]  -> suml[y] - suml[x - 1], sumr[x] - sumr[y - 1]

int main() {
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	sort(A, A + N);
	
	dpl[0] = 1;
	for (int j = 0; j < K; j++) {
		suml[0][j + 1] = suml[0][j] + dpl[j];
	}
	for (int i = 0; i < N; i++) {
		if(A[i] <= K)dpl |= (dpl << A[i]);
		for (int j = 0; j < K; j++) {
			suml[i + 1][j + 1] = suml[i + 1][j] + dpl[j];
		}
	}

	dpr[0] = 1;
	for (int j = 0; j < K; j++) {
		sumr[N][j + 1] = sumr[N][j] + dpr[j];
	}
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] <= K)dpr |= (dpr << A[i]);
		for (int j = 0; j < K; j++) {
			sumr[i][j + 1] = sumr[i][j] + dpr[j];
		}
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (K - A[i] <= 0)continue;
		bool f = true;
		for (int j = 1; j < K; j++) {
			//左右二つの情報のどれをとっても、[K - A[i], K)にないならば答え
			if (i == 0) {
				if (sumr[i + 1][K] - sumr[i + 1][K - A[i]]) {
					f = false;
				}
				break;
			}
			else if ((suml[i][j + 1] - suml[i][j]) == 1) {
				
				if (j < K - A[i]) {
					if (sumr[i + 1][K - j] - sumr[i + 1][K - A[i] - j]) {
						f = false;
					}
				}
				else {
					f = false;
				}
			}
		}
		if (f)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 196224
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define debug(x) cout << x << endl;
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int N = 1e7+1;
const int mod = 1e9+7;
const int INF = 1e18;

void solve() {
	int a,v,b,w,t;
	cin >> a >> v >> b >> w >> t;
	if(b > a) {
		if(a + v*t >= b + w*t)
			cout << "YES";
		else
			cout << "NO";
	} else {
		if(a - v*t <= b - w*t)
			cout << "YES";
		else
			cout << "NO";
	}
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }

inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }



int main()
{
int n,l;
cin >> n >> l;
int a[n];
REP(i,n)
int a[i];
int ind=-1;
REP(i,n)
    cin >>a[i];
REP(i,n-1)
{
    if(a[i]+a[i+1]>=l)
    {
        ind=i+1;
        break;
    }
}

if(ind==-1)
{
    cout<<"Impossible\n";
    return 0;
}
    cout<<"Possible\n";

for(int i=1;i<n;i++)
{
    if(i!=ind)
        printf("%d\n",i);
    if(i==ind)
        break;
}
for(int i=n-1;i>=1;i--)
{
    if(i==ind )
        break;
        printf("%d\n",i);
        
}
printf("%d\n",ind);

}

Measured memory_bytes: 1152
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n,h,w=MI()
    count=0
    for i in range(n):
        x,y=MI()
        if h<=x and w<=y:
            count+=1
    print(count)
        
        
        
        
    
if __name__=="__main__":
    main()



Measured memory_bytes: 67772
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    l, r = map(int, input().split())
    if r-l >= 2018:
        print(0)
    else:
        ans = 2222
        n = [i for i in range(l, r+1)]
        for i in range(len(n)):
            for j in range(i+1, len(n)):
                s = n[i]*n[j] % 2019
                if ans > s:
                    ans = s
        print(ans)

        # n = [[i % 2019, i] for i in range(l, r+1)]
        # n.sort(key=lambda x: x[0])
        # print((n[0][1]*n[1][1]) % 2019)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38896
from collections import defaultdict
N = int(input())
S = list(input())
MOD = 10 ** 9 + 7

dic = defaultdict(int)

for i in S:
    dic[i] += 1

ans = 1
for i in dic:
    ans *= dic[i] + 1
    ans %= MOD

print (ans - 1)

Measured memory_bytes: 4340
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 5005;


void solve()
{
	int n; cin >> n;
	ll sum = 0;
	vector<ll> v(n);
	FOR(i, 0, n) cin >> v[i];
	ll x = v[0];
	FOR(i, 1, n)
	{
		sum = (sum + (v[i] * x)) % mod;
		x = (x + v[i]) % mod;
	}
	cout << sum << "\n";
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    /*int tc;  cin >> tc;
    while (tc--)*/
    solve();
    return 0;
}







Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <assert.h>
using namespace std;

struct card{char suit; int  value;};

void trace(struct card cards[],int N)
{
    int i;
    for(i=0;i<N-1;i++){
        cout<<cards[i].suit<<cards[i].value<<" ";
    }
    cout<<cards[i].suit<<cards[i].value<<endl;
}

bool cmp(struct card card1[], struct card card2[],int N);
void selectsort(struct card cards [],int N)
{
    for(int i=0;i<N;i++){
        int minx=i;
        for(int j=i;j<N;j++){
            if(cards[j].value<cards[minx].value) minx=j;
        }
        swap(cards[i],cards[minx]);
    }
}
void bubblesort(struct card cards[],int N)
{
    for(int i=0;i<N;i++){
        for(int j=i;j>0;j--){
            if(cards[j].value<cards[j-1].value)
                swap(cards[j],cards[j-1]);
        }
    }

}
bool cmp(struct card card1[], struct card card2[],int N)
{
    for(int i=0;i<N;i++){
        if(card1[i].suit!=card2[i].suit) return false;
    }
    return true;
}
int main()
{
    int n;
    cin>>n;
    assert(n<=36);
    card card1[100];
    card card2[100];
    for(int i=0;i<n;i++){
        cin>>card1[i].suit>>card1[i].value;
    }
    for(int i=0;i<n;i++){
        card2[i]=card1[i];
    }
    bubblesort(card1,n);
    selectsort(card2,n);
    trace(card1,n);
    cout<<"Stable"<<endl;
    trace(card2,n);
    if(cmp(card1,card2,n)) cout<<"Stable"<<endl;
    else cout<<"Not stable"<<endl;
    return 0;
}



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

using namespace std;
using ll = long long;

int main() {
	int N;
	cin >> N;

	ll k = 1;
	bool ok = false;
	while (k * k - k <= 2 * N) {
		if (k * k - k == 2 * N) {
			ok = true;
			break;
		}
		++k;
	}

	if (!ok) {
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
	cout << k << endl;

	vector<vector<int>> s(k);
	int n = 1;
	int idx = k - 1;
	for (int i = 0; i < k; ++i) {
		while (s[i].size() < k - 1) {
			s[i].push_back(n);
			s[idx].push_back(n);
			++n;
			--idx;
			if (idx <= i) { break; }
		}
		idx = k - 1;
	}

	for (int i = 0; i < s.size(); ++i) {
		cout << s[i].size() << " ";
		for (int j = 0; j < s[i].size(); ++j) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 2304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
//#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void swap2(double* a, double* b)
{
	double tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

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

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

int factorial(int n)
{
	int a=1;

	if (n == 0)
		return 1;

	for (int i = 1; i <= n; i++)
		a *= i;

	return a;
}

int Con(int a, int b)
{
	return factorial(a) / (factorial(b) * factorial(a - b));
	
}

int a[20] = { 0 };

//int binary_search(int key)  
//{
//	int low, high, middle;
//
//	low = 0;
//	high = 20 - 1;
//
//
//
//	while (low <= high)
//	{
//		middle = (low + high) / 2;
//		if (key == a[middle])
//			return middle;
//		else if (key < a[middle])
//			high = middle - 1;
//		else if (key > a[middle])
//			low = middle + 1;
//	}
//	return INF;
//}

int binary_search(long long int key)
{
	long long int low = 0, high = 2000000000, middle;
	long long int p;

	while (low <= high)
	{
		middle = (low + high) / 2;
		//printf("%d    \n", middle);

		p = (middle * (middle + 1));

		if (p == key*2)
			return middle;
		else if (p >key*2)
			high = middle - 1;
		else
			low = middle + 1;
	}
	return 0;

}

int main()
{
	char S[11], T[11],U[11];
	int A, B;

	scanf("%s%s%d%d%s", S, T, &A, &B,U);

	if (strcmp(S, U) == 0)
		printf("%d %d", A - 1, B);
	else
		printf("%d %d", A, B - 1);

}


Measured memory_bytes: 888
N = input()
n = N[-1:]

if n == "2" or n == "4" or n == "5" or n == "7" or n == "9":
    print("hon")
elif n == "0" or n == "1" or n == "6" or n == "8":
    print("pon")
elif n == "3":
    print("bon")

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

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a==b and b==c)
        cout << 1 << endl;
    else if(a==b or b==c or c==a)
        cout << 2 << endl;
    else
        cout << 3 << endl;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	std::string s;
	std::cin >> s;
	int n = s.size();
	std::vector<std::vector<int> > dp(n,std::vector<int>(2,0));
	dp[0][0] = s[0]-'0';
	dp[0][1] = 11-(s[0]-'0');
	rep(i,n-1) {
		int d = s[i+1]-'0';
		dp[i+1][0] = std::min(dp[i][0],dp[i][1])+d;
		dp[i+1][1] = std::min(dp[i][0]+11-d,dp[i][1]+9-d);
	}
	debug(dp);
	print(std::min(dp[n-1][0],dp[n-1][1]));

	return 0;
}


Measured memory_bytes: 55940
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = (1 << 31)-1;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
struct segmenttree{
  	vint  value;
  	int N;
  	segmenttree(int n){
      	N=1;
      	while(N<n){
          	N*=2;
        }
      	value = vector<int>(2*N-1,INF);
    }
  	void update(int i,int x){
      	i+=N-1;
      	value[i]=x;
      	while(i>0){
          	i=(i-1)/2;
          	value[i]=min(value[i*2+1],value[i*2+2]);
        }
    }
    int query(int a,int b,int k,int l,int r){
      	if(r<=a || b<=l){
          	return INF;
        }
      	else if(a<=l && r<=b){
          	return value[k];
        }
		else{
          	int c1=query(a,b,2*k+1,l,(l+r)/2);
          	int c2=query(a,b,2*k+2,(l+r)/2,r);
          	return min(c1,c2);
        }
    }
};
          
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 	 int n,q;
  	cin>>n>>q;
  	segmenttree sg(n);
  	int com,x,y;
  	rep(i,q){
      	cin>>com>>x>>y;
      	if(com==0){
          	sg.update(x,y);
        }
      	else{
          	cout<<sg.query(x,y+1,0,0,sg.N)<<'\n';
        }
    }
  	return(0);
}



Measured memory_bytes: 5012
A, B = map(int, input().split())

import fractions

AB_gcd = fractions.gcd(A, B)

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

c = make_divisors(AB_gcd)
c.sort()
for i, x in enumerate(c):
	if i == 0:
		continue
	if x == 0:
		continue
	for j in range(i+1,len(c)):
		if c[j] % x == 0:
			c[j] = 0

print(len([ans for ans in c if ans != 0]))

Measured memory_bytes: 5300
// segment tree (abstract version)

#include <bits/stdc++.h>

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

using namespace std;


template<class T>
class add_monoid{
	T a;
public:
	add_monoid(const T& val=T()):a(val){}
	static add_monoid unit(){ return add_monoid(); }
	add_monoid operator*(const add_monoid& x)const{
		return a+x.a;
	}
	int to_int()const{ return int(a); }
};

template<class T>
class sequence_monoid{
	vector<T> a;
public:
	sequence_monoid(){}
	sequence_monoid(const T& val):a(1,val){}
	sequence_monoid(const vector<T>& x):a(x){
		sort(a.begin(),a.end());
	}
	static sequence_monoid unit(){ return sequence_monoid(); }
	sequence_monoid operator*(const sequence_monoid& x)const{
		vector<T> res;
		merge(a.begin(),a.end(),x.a.begin(),x.a.end(),back_inserter(res));
		return res;
	}
	int lower_bound(const T& val)const{
		return std::lower_bound(a.begin(),a.end(),val)-a.begin();
	}
};

template<class M>
class segment_tree{
	int sz;
	vector<M> seg;
public:
	segment_tree(){}
	segment_tree(int n){ build(n); }
	segment_tree(const vector<M>& a){ build(a); }
	void build(int n){
		for(sz=1;sz<n;sz<<=1);
		seg.assign(2*sz,M::unit());
	}
	void build(const vector<M>& a){
		int n=a.size();
		build(n);
		rep(i,n) seg[sz+i]=a[i];
		for(int i=sz-1;i>0;i--){
			seg[i]=seg[2*i]*seg[2*i+1];
		}
	}
	template<class N,class F>
	N query(int l,int r,const F& f){
		N lcum=N::unit(),rcum=N::unit();
		for(int a=l+sz,b=r+sz;a<b;a>>=1,b>>=1){
			if(a&1) lcum=lcum*f(seg[a++]);
			if(b&1) rcum=f(seg[--b])*rcum;
		}
		return lcum*rcum;
	}
};

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]), a[i]--;

	vector<sequence_monoid<int>> x(n);
	vector<int> pre(n,-1);
	rep(i,n){
		x[i]=pre[a[i]];
		pre[a[i]]=i;
	}

	segment_tree<sequence_monoid<int>> S(x);
	rep(_,q){
		int l,r; scanf("%d%d",&l,&r); l--;
		auto ans=S.query<add_monoid<int>>(l,r,[&](const sequence_monoid<int>& x)->add_monoid<int>{
			return x.lower_bound(l);
		});
		printf("%d\n",ans.to_int());
	}

	return 0;
}


Measured memory_bytes: 125556
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
int a,b,c;
  cin>>a>>b>>c;
  cout<<(c/a)*b;
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,m,x;
 cin>>n>>m>>x;
 vector<int> a(m);
 for(int i=0; i<m; i++){
   cin>>a.at(i);
 }
 int right=0,left=0;
 for(int i=0; i<m; i++){
   if(a.at(i)<x) ++left;
   else ++right;
 }
 cout<<min(left,right)<<endl;
}

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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll divisibles(ll a, ll b, ll m){if(a%m==0)return (b/m)-(a/m)+1;else return (b/m)-(a/m);}// in [a,b]

vi p(100001);
vi bulb[100001];
int n,m;
int cntboss=0;
void recurse(vi &vec, int index)
{
	if(index==vec.size())
	{
		int cntx=0;
		for(int i=1; i<=m; ++i)
		{
			int cnt=0;
			//cout<<i<<" ";
			for(int j=0; j<bulb[i].size(); ++j)
			{
			//	cout<<bulb[i][j]<<" ";
				if(vec[bulb[i][j]-1]==1)
					++cnt;
			}
			if((cnt-p[i])%2==0)
				++cntx;
			//cout<<"\n";
		}
		if(cntx==m)
			++cntboss;
		//cout<<"\n";
		return;
	}
	vec[index]=1;
	recurse(vec,index+1);
	vec[index]=0;
	recurse(vec,index+1);
}


int main()
{	
    std::ios::sync_with_stdio(false);
    //srand(time(0));
    //cin.tie(NULL);
    //cout.tie(NULL);
    cin>>n>>m;
    vi states(n,-1);
    for(int i=1; i<=m; ++i)
    {
    	int x;cin>>x;
    	for(int j=0; j<x; ++j)
    	{
    		int y;cin>>y;
    		bulb[i].pb(y);
    	}
    }
    for(int i=0; i<m; ++i)
    {
    	int x;cin>>x;
    	p[i+1]=x;
    }
    recurse(states,0);
    cout<<cntboss<<"\n";


}

Measured memory_bytes: 2944