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

#define fastio 

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

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

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int n, k;
  cin >> n >> k;
  int ans = 0;
  int vals[k + 1];
  for(int i = 1; i <= k; i++){
    vals[i] = modexpo(k / i, n);
  }
  for(int i = k; i >= 1; i--){
    for(int j = 2*i; j <= k; j += i){
      vals[i] = sub(vals[i], vals[j]);
    }
    ans = add(ans, mul(vals[i], i));
  }
  cout << ans << '\n';
}

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

  pre();

  int t = 1, T;
  // cin >> t;
  T = t;
  while(t--){
    // cout << "Case #" << T - t << ": ";
    solve();
  }

  ktj();
}


Measured memory_bytes: 4244
#include <stdio.h>

int main(void) {
	// your code goes here
	int S,h,m,s;
	scanf("%d",&S);
	h = S / 3600;
	S = S % 3600;
	m = S / 60;
	S = S % 60;
	s = S;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}



Measured memory_bytes: 2740
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int MOD = 1000000007;
int color[8];
main(){
    int N,cnt = 0;
    cin >> N;
    for(int i = 0;i < N;i++){
        int c;
        cin >> c;
        if(c < 3200)color[c/400] = 1;
        else cnt++;
    }
    int num = accumulate(color,color+8,0);
    if(num){
        cout << num << " " << num+cnt << endl;
    }else{
        cout << "1 " << cnt << endl;
    }
}

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

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

    int n;
    int A[100005];
    int B[100005];
    int C[100005];
    cin>>n;
    int dp[100005][3]={0};

    for (int i = 0; i < n; ++i)
    {
    	cin>>A[i]>>B[i]>>C[i];
    }
    for (int i = 0; i < n; ++i)
    {
    	for (int j = 0; j <3 ; ++j)
    	{
    		if(i==0) { 
    			if(j==0) dp[i][j]=A[i];
    			else if(j==1) dp[i][j]=B[i];
    			else  dp[i][j]=C[i];
    		}
    		else {
    		for (int k = 0; k < 3; ++k)
    		{
    			if(j==k) continue;
    			if(j==0) {dp[i][j]=max(dp[i][j],dp[i-1][k]+A[i]);}
    			else if(j==1) {dp[i][j]=max(dp[i][j],dp[i-1][k]+B[i]);}
    			else  {dp[i][j]=max(dp[i][j],dp[i-1][k]+C[i]);}
    		}
    		}

    	}
    }
    int result=max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    cout<<result;

}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

const int N = 100010;

int n;
int a[N], b[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    scanf("%d", &a[i]);
  if (count(a + 1, a + n + 1, 0) == n) {
    puts("Yes");
    return 0;
  }
  if (n % 3) {
    puts("No");
    return 0;
  }
  sort(a + 1, a + n + 1);
  copy(a + 1, a + n + 1, b + 1);
  int m = unique(b + 1, b + n + 1) - b - 1;
  if (m == 2 && b[1] == 0 && count(a + 1, a + n + 1, 0) == n / 3) {
    puts("Yes");
  } else if (m == 3 && (b[1] == (b[2] ^ b[3])) && count(a + 1, a + n + 1, b[1]) == n / 3 && count(a + 1, a + n + 1, b[2]) == n / 3 && count(a + 1, a + n + 1, b[3]) == n / 3)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
    return e1.cost<e2.cost;
}
vector<edge>v;
int n;
int par[111111],ran[111111];
void init(){
    rep(i,n){
        par[i]=i;
        ran[i]=0;
    }
}
int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
}
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;
    if(ran[x]<ran[y])par[x]=y;
    else{
        par[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}
bool same(int x,int y){
    return find(x)==find(y);
}
int kruskal(){
    sort(v.begin(),v.end(),comp);
    init();
    int res=0;
    for(edge e:v){
        if(!same(e.u,e.v)){
            unite(e.u,e.v);
            res+=e.cost;
        }
    }
    return res;
}
pair<pair<int,int>,int>px[111111],py[111111];
signed main() {
    cin>>n;
    rep(i,n){
        int x,y;
        cin>>x>>y;
        px[i]={{x,y},i};
        py[i]={{y,x},i};
    }
    sort(px,px+n);
    sort(py,py+n);
    for(int i=1;i<n;i++){
        v.push_back({px[i].second,px[i-1].second,min(abs(px[i].first.first-px[i-1].first.first),abs(px[i].first.second-px[i-1].first.second))});
        v.push_back({py[i-1].second,py[i].second,min(abs(py[i].first.first-py[i-1].first.first),abs(py[i].first.second-py[i-1].first.second))});
    }
    cout<<kruskal()<<endl;
	return 0;
}

Measured memory_bytes: 14704
#include <bits/stdc++.h>
#define X first
#define Y second
 
using namespace std;
typedef long long llint;
 
const int maxn = 2e5+10;
const int base = 31337;
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int logo = 20;
const int off = 1 << logo;
const int treesiz = off << 1;

string a, b;
int main() {
	cin >> a >> b;
	int sol = inf;
	for (int i = 0; i <= a.size() - b.size(); i++) {
		int tren = 0;
		for (int j = 0; j < b.size(); j++) {
			if (a[i + j] != b[j]) tren++;
		}
		sol = min(sol, tren);
	}
	cout << sol;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100000;
constexpr ll A_MAX = 1000000000;
constexpr ll H_I_MAX = 1000000000;

ll N, A, B;
ll h[N_MAX];

// index が条件を満たすかどうか
bool isOK(int index) {
	ll AB=A-B;
	ll nokori=index;
	rep(i,N){
		ll t=h[i]-index*B;
		if(t<=0)continue;
		ll s=(t+AB-1)/AB;
		nokori-=s;
		if(nokori<0)return false;
	}
	return true;
}

// 汎用的な二分探索のテンプレ
int binary_search() {
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = 0; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	rep(i,N){
		ll t=(h[i]+B-1)/B;
		chmax(ok,t);
	}
	
    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid)) ok = mid;
        else ng = mid;
    }
    return ok;
}

void input() {
	scanf("%lld%lld%lld", &N, &A, &B);
	rep(i, N) scanf("%lld", h + i);
}

void solve() {
	int ans = binary_search();
	printf("%d\n", ans);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<queue>
using namespace std;
int main(){
	int n, ap=0, bp=0;
	string a, b;


	cin >> n;

	for (int i = 0; i < n; ++i){
		cin >> a >> b;


		int j = 0;
		while (true){
			if (a[j] == '\0' && b[j] == '\0'){ ++ap; ++bp; break; }
			else if (a[j] > b[j] || b[j] == '\0'){ ap+=3; break; }
			else if (a[j] < b[j] || a[j] == '\0'){ bp+=3; break; }
			++j;
		}
	}

	cout << ap << " " << bp << endl;

}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> X(N);for(int i=0;i<N;i++)cin>>X[i];
  
  vector<pair<int,int>> P;
  for(int i=0;i<N;i++)P.push_back(pair<int,int>(X[i],i));
  
  sort(P.begin(),P.end());
  
  vector<int> M(N);
  for(int i=0;i<N;i++){
    if(i<N/2) M[P[i].second]=P[N/2].first;
    else M[P[i].second]=P[N/2-1].first;
  }
  for(int i=0;i<N;i++) cout<<M[i]<<endl;
}

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

int main(){
  int N;
  int c=0;
  int i;
  cin>>N;
  for(int a=1;a<=N-1;a++){
  i=(N-1)/a;
    
 //   cout<<N<<a<<i<<endl;
   c+=i; 
  }
cout<<c<<endl;  
}



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

using namespace std;

typedef long long LL;

const int maxn=3005;
const int INF=0x3f3f3f3f;
const int MOD=1e9+7;

struct Question{
	int l,r;
}q[maxn],p[maxn];

LL C[maxn][maxn],dp[maxn][maxn];
int sum[maxn];
char s[maxn];
int n,m;

void pre_C(){
	for(int i=0;i<=n;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;
		}
	}
}

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	pre_C();
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+s[i]-'0';
	int cnt=0;
	for(int i=1;i<=m;++i)scanf("%d%d",&p[i].l,&p[i].r);
	for(int i=1;i<=m;i++)
	{
		if(p[i].l==p[i+1].l&&p[i].r<=p[i+1].r){
			continue;
		}
		int j=i+1;
		while(p[i].l<=p[j].l&&p[i].r>=p[j].r&&j<=m)
		{
			++j;
		}
		q[++cnt].l=p[i].l;q[cnt].r=p[i].r;
		i=j-1;
	}m=cnt;
	q[m+1].l=n+1;q[m+1].r=n+1;
	sum[n+1]=sum[n];
	dp[1][sum[q[1].r]-sum[q[1].l-1]]=1;
	for(int i=1;i<=m;i++){
		if(q[i].r<q[i+1].l){
			int len=q[i].r-q[i].l+1;
			for(int j=0;j<=len;j++){
				dp[i+1][sum[q[i+1].r]-sum[q[i+1].l-1]]+=dp[i][j]*C[len][j]%MOD,dp[i+1][sum[q[i+1].r]-sum[q[i+1].l-1]]%=MOD;
			}
		}
		else{
			int LEN=q[i].r-q[i].l+1;//qujianchang
			int len=q[i].r-q[i+1].l+1;//jiaojichang
			int pre=q[i+1].l-q[i].l;//qianzhui
			for(int j=0;j<=LEN;j++)
				for(int k=max(0,j-pre);k<=j&&k<=len;k++){
					dp[i+1][sum[q[i+1].r]-sum[q[i].r]+k]+=dp[i][j]*C[pre][j-k]%MOD,dp[i+1][sum[q[i+1].r]-sum[q[i].r]+k]%=MOD;
				}
		}
	}
	printf("%lld\n",dp[m+1][0]);
	return 0;
}

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

ans = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return set(a)

prime_list = prime_factorize(N)

# 通ったやつ
# if prime_list:
#     for prime_num in prime_list:
#         if N % prime_num == 0:
#             for j in range(1, 100):
#                 if N < prime_num**j:
#                     break
#                 if N % prime_num**j == 0:
#                     N //= prime_num**j
#                     ans += 1

# 通ってないやつ
if prime_list:
    for prime_num in prime_list:
        if N % prime_num == 0:
            i = 1
            while N % prime_num**i == 0:
                N //= prime_num**i
                ans += 1
                i += 1


print(ans)


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

 int main(){
   int H, W;


   while (1){
     cin >> H >> W;
     if ( H == 0 && W == 0 ) break;

     for ( int i = 0; i < H; i++ ){
       for (int j = 0; j < W; j++ ){
         if ( i == 0 || i == H-1 || j == 0 || j == W-1 ){
          cout << "#";
         } else {
           cout << ".";
         }
       }
       cout << "\n";
     }
     cout << endl;
   }

   return 0;
}   

Measured memory_bytes: 1152
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);


bool gd(int n){
	return(n%7==1||n%7==6);
}

int main(){
	vi gds;
	FOR(i,2,300001){
		if(gd(i)){
			gds.push_back(i);
		}
	}
	vi gdp;
	REP(i,gds.size()){
		bool ok=true;
		for(int j=2;j*j<min(gds[i]+1,300001);j++){
			if(gd(j)&&gds[i]%j==0){
				ok=false;
				break;
			}
		}
		if(ok){
			gdp.push_back(gds[i]);
		}
	}
	int n;
	while(cin>>n,n!=1){
		cout<<n<<":";
		REP(i,gdp.size()){
			if(n%gdp[i]==0){
				cout<<" "<<gdp[i];
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1720
#include <iostream>
#define NMAX 100002
#define INF (int)1e9

using namespace std;
int N,A[NMAX][3],dp[NMAX][3];

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < 3; ++i)
	{
		dp[0][i] = A[0][i];
	}
	for (int i = 1; i < N; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
			{
				if(j != k){
					dp[i][j] = max(dp[i-1][k]+A[i][j],dp[i][j]);
				}
			}
		}	
	}
	int ans = 0;
	for (int i = 0; i < 3; ++i)
	{
		ans = max(ans,dp[N-1][i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

#define N 100010
#define LLINF 2000000000000000000LL

int sum[N][3];
ll dp1[N][5],dp2[N][5];

int main(){
  int n,st[N];
  char s[N];

  scanf("%d%s",&n,s);

  for(int i=1;i<=n;i++){
    if(s[i-1]=='J') st[i]=1;
    if(s[i-1]=='O') st[i]=2;
    if(s[i-1]=='I') st[i]=3;

    sum[i][st[i]]++;
  }

  for(int i=1;i<=n;i++){
    for(int j=0;j<3;j++){
      sum[i+1][j] += sum[i][j];
    }
  }

  ll ans = 0;

  dp1[0][0] = 1;

  for(int i=1;i<=n;i++){
    dp1[i][st[i]] += dp1[i-1][st[i]-1];
    for(int j=0;j<=4;j++){
      dp1[i][j] += dp1[i-1][j];
    }
  }

  dp2[n+1][4] = 1;

  for(int i=n;i>=1;i--){
    dp2[i][st[i]] += dp2[i+1][st[i]+1];
    for(int j=0;j<=4;j++){
      dp2[i][j] += dp2[i+1][j];
    }
  }

  for(int i=0;i<=n;i++){
    for(int j=1;j<=4;j++){
      ans = max(ans,dp1[i][j-1] * dp2[i+1][j+1]);
    }
  }

  printf("%lld\n",ans + dp1[n][3]);

  return 0;
}

Measured memory_bytes: 12644
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;



const int mod = 1e9+7;
vector<string> s={"AACG","AAGC","ACGA","ACGC","ACGG","ACGT","AGAC","AGCA","AGCC","AGCG","AGCT","AGGC","AGTC","ATGC","CACG","CAGC","CGAC","GACA","GACC","GACG","GACT","GAGC","GGAC","TACG","TAGC","TGAC","AGC","GAC","ACG"};
string all="ACGT";
map<pair<int,string>,int>mp;
set<string>bad;
int n;
int solve(int i,string s){
	if( bad.count(s) )return 0;
	if( i == n )return 1;
	if( mp.find({i,s})!=mp.end() )return mp[{i,s}];
	mp[{i,s}]=0;
	for(int k=0;k<4;k++){
		string cur = s + all[k];
		if( cur.length() == 5u ){
			cur = cur.substr(1,4);
		}
		mp[{i,s}]+=solve(i+1,cur);
		mp[{i,s}]%=mod;
	}
	return mp[{i,s}];
}
int32_t main(){
	IOS
	for(size_t i=0;i<s.size();i++){
		bad.insert(s[i]);
	}
	cin>>n;
	cout<<solve(0,"");
}
 
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 5660
import sys
input = sys.stdin.readline
import numpy as np
from collections import defaultdict

N,K = map(int,input().split())
# 全要素を-1する
A = [0] + [int(i)-1 for i in input().split()]

# Acum[i]: A[1]からA[i]までの累積和
Acum = np.cumsum(A)
Acum = [i%K for i in Acum]

answer = 0
counter = defaultdict(int)

# iの範囲で探索
# 1 <= j <= N
# j-K+1 <= i <= j-1
for j,x in enumerate(Acum):
    # (i-K+1)回目から(i-1)回目の探索において、xの出現回数
    answer += counter[x]
    # i回目の結果を辞書に追加
    counter[x] += 1
    # 辞書にK回追加した場合
    if j-K+1 >= 0:
        # 辞書から一番古い探索記録を削除
        counter[Acum[j-K+1]] -= 1

print(answer)

Measured memory_bytes: 50904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;


// 根が1 !!!!!
template<typename Monoid>
struct segtree {
    using T = typename Monoid::T;
    int n;
    vector<T> dat;

    segtree(int n_) {
        n = 1;
        while(n < n_) n <<= 1;
        dat.assign(n*2, Monoid::id());
    }
    void build(vector<T> v) {
        REP(i, v.size()) dat[i+n] = v[i];
        for(int i=n-1; i>0; --i) dat[i] = Monoid::op(dat[i*2], dat[i*2+1]);
    }

    T query(int a, int b) {
        T l = Monoid::id(), r = Monoid::id();
        for(a+=n, b+=n; a<b; a>>=1, b>>=1) {
            if(a&1) l = Monoid::op(l, dat[a++]);
            if(b&1) r = Monoid::op(dat[--b], r);
        }
        return Monoid::op(l, r);
    }
    void update(int i, T v) {
        i += n;
        dat[i] = v;
        while(i >>= 1) {
            dat[i] = Monoid::op(dat[i*2], dat[i*2+1]);
        }
    }

    friend ostream &operator <<(ostream& out,const segtree<Monoid>& seg){
        out << "---------------------" << endl;
        int cnt = 1;
        for(int i=1; i<=seg.n; i*=2) {
            REP(j, i) {
                out << seg.dat[cnt] << " ";
                cnt++;
            }
            out << endl;
        }
        out << "---------------------" << endl;
        return out;
    }
};

template<typename Tp>
struct min_monoid {
    using T = Tp;
    static constexpr Tp id() { return INF; }
    static Tp op(const Tp &a, const Tp &b) { return min(a, b); }
};

int main(void) {
    ll n, m;
    cin >> n >> m;
    string s;
    cin >> s;

    segtree<min_monoid<ll>> seg(n+1);
    seg.update(n, 0);
    for(ll i=n-1; i>=0; --i) {
        if(s[i] == '1') continue;
        ll ret = seg.query(i+1, min(n+1, i+m+1));
        seg.update(i, ret+1);
    }
    dump(seg);

    if(seg.query(0, 1) >= INF) {
        cout << -1 << endl;
        return 0;
    }
    
    vector<ll> dp(n+1);
    REP(i, n+1) dp[i] = seg.query(i, i+1);
    dump(dp);

    vector<ll> v(n+1, INF);
    REP(i, n+1) {
        if(dp[i] >= INF) continue;
        dump(i, dp[i]);
        chmin(v[dp[i]], i);
    }
    dump(v);
    
    ll ans = seg.query(0, 1);
    for(ll i=ans; i>=1; --i) cout << v[i-1]-v[i] << (i==1 ? '\n': ' ');
    cout << flush;

    return 0;
}

Measured memory_bytes: 4304
import java.util.Scanner;

/**
 *
 * @author must
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        double tmax=0;
        for (int i=2;i<10;i++){
            for(int k=1;k<32;k++){
                double t = Math.pow(k, i);
                //System.out.println(t);
                if(t > tmax && t<=X){
                    tmax = t;
                    if(t==X){
                        break;
                    }
                }else if(t>X){
                    break;
                }
                
            }
        }
        int ans = (int)tmax;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[4]={};
	cin>>a[1]>>a[2]>>a[3];
	sort(a+1,a+4);
	cout<<a[1]<<' '<<a[2]<<' '<<a[3]<<endl;
	return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n;
	while(cin>>n)
	{
		int a[3]={0};
		a[2]=n%10;
		a[1]=n/10%10;
		a[0]=n/100;
		if(a[0]==a[1]&&a[1]==a[2])
		{
			cout<<n<<endl;
			//return 0;
		}
		else if(a[1]>a[0])
		{
			cout<<a[0]+1<<a[0]+1<<a[0]+1<<endl;
			//return 0;
		}
		else if(a[1]==a[0])
		{
			if(a[1]>=a[2])
			{
				cout<<a[0]<<a[1]<<a[1]<<endl;
				//return 0;
			}
			else
			{
				cout<<a[0]+1<<a[0]+1<<a[0]+1<<endl;
				//return 0;
			}
			
		}
		else if(a[1]<a[0])
		{
			cout<<a[0]<<a[0]<<a[0]<<endl;
			//return 0;
		}
		
		
	}
	
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FS fs = new FS();
        int n = fs.nextInt();
        int sum = 0;
        for (int i = 0; i < n; i++) {
            int m = fs.nextInt();
            if (test(m)) sum++;
        }
        System.out.println(sum);
    }

    private static boolean test(int m) {
        if (m == 2) return true;
        else if (m == 3) return true;
        else {
            if (m%2==0)return false;
            if (m%3==0)return false;
            for (int i = 5; i < Math.sqrt(m)+1; i += 6) {
                if (m % i == 0) return false;
                 if (m % (i+2) == 0) return false;
            }
            return true;
        }
    }

}


 class FS {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        return hasNextByte() ? buffer[ptr++] : -1;
    }

    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
        skipUnprintable();
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public int nextInt() {
        return (int) nextLong();
    }

    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
}




Measured memory_bytes: 25992
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n == 1) {
            System.out.println(1);
            return;
        }
        long[] arr = new long[n];
        for(int i = 0; i < n; i++)
            arr[i] = sc.nextInt();

        int cnt = 0;
        long diff = 0;
        for(int i = 1; i < n; i++) {
            long temp = arr[i] - arr[i-1] ;
            if(temp == 0) continue;

            if(temp * diff < 0) {
                cnt++;
                diff = 0;
            }
            else
                diff = temp;
        }
        System.out.println(cnt + 1);
    }
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> P;
#define INF 10000000000000
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define repN_1(i, n) for(int i = 0; i < (int)(n - 1); i++)
#define repM(i, n) for(int i = (int)(n - 1); i >= 0; i--)
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 (b < a) { a = b; return 1; } return 0; }

int main()
{
	cout << fixed << setprecision(10);

	int N;
	vector<P> town;
	double sum = 0.0;
	int count = 0;

	cin >> N;

	rep(i, N)
	{
		int x, y;
		cin >> x >> y;
		town.push_back(make_pair(x, y));
	}

	repN_1(i, N)
	{
		for(int j = i + 1; j < N; j++)
		{
			sum += sqrt(pow(town[i].first - town[j].first, 2) + pow(town[i].second - town[j].second, 2));
			count++;
		}
	}

	cout << (sum / count) * (N - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
ll n , a[N] , q ;

int main ( ){
  scanf("%lld",&n);
 vector < ll > d ;
  for  ( ll i=  1; i*i <= n;  i++ ) {
    if ( n%i == 0 ) {
        d.push_back(i);
        d.push_back(n/i);
    }
  }
  sort(d.begin(),d.end());
  printf("%lld\n",d[d.size()/2-1]+d[d.size()/2]-2LL);
return 0 ;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = INT_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;
	while (tc--) {

		ll n, m, l, r;
		ll i, j;
		ll y;

		char ch;
		cin >> ch;

		if (ch >= 'a' and ch <= 'z') {
			cout << "a" << endl;
		}
		else
			cout << "A" << endl;

	}
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int k;
  cin >> k;
  cout << a[k - 1];
}

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

namespace procon
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(int.Parse).ToArray();
            
            Console.WriteLine("{0} {1} {2:0.00000}",inputs[0]/inputs[1], inputs[0]%inputs[1], (double)inputs[0]/(double)inputs[1]);
        }
    }
}

Measured memory_bytes: 9732
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()

A = []
for _ in range(2):
  A.append(reads())

result = max(sum(A[0][:i+1]) + sum(A[1][i:]) for i in range(N))
print(result)

Measured memory_bytes: 3828
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;

	if (N == 1) {
		if (A == B) {
			cout << 1 << endl;
		} else {
			cout << 0 << endl;
		}
		return 0;
	}

	if (A > B) {
		cout << 0 << endl;
		return 0;
	}

	ll min_sum = A * (N - 1) + B;
	ll max_sum = A + B * (N - 1);

	ll res = max_sum - min_sum + 1;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int []po=new int[n];
  boolean b=false;
  for(int i=0;i<n;i++){
  	po[i]=sc.nextInt();
  }
    int num=0;
    int i=0;
    for(;i<n;i++){
    	num=po[num]-1;
      if(num==1){b=true;break;}
    }
    System.out.println(b?i+1:-1);
  
}
}


Measured memory_bytes: 51128
N = int(input())
a = list(map(int,input().split())) 
c = [False]*8

overRed = 0

for i in a:
  ide = i // 400
  if 8 <= ide:
      overRed += 1
  else:
      c[ide] = True

min_num = 1 if c.count(True) == 0 and overRed != 0 else c.count(True)
max_num = c.count(True)+overRed

print(min_num,max_num)
    

Measured memory_bytes: 3060
import itertools
 
N, M = map(int, input().split())
a = [[0] * 10] * N
 
for i in range(N):
  if i == 0:
    a[i] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
  else:
    a[i] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 
flag = 1
 
for i in range(M):
  s, c = map(int, input().split())
  if (N > 1 and s == 1 and c == 0) or (len(a[s-1]) == 1 and a[s-1] != [c]):
    flag = 0
  a[s-1] = [c]
 
if N == 1 and M == 0:
  print(0)
elif flag == 0:
  print(-1)
else:
  list_a = list(itertools.product(*a))
  ans = ""
  for i in range(N):
    ans += str(list_a[0][i])
  print(int(ans))

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int loop,n;
    scanf("%d",&n);
    int r[n];
    for(loop=0;loop<n;++loop){
        scanf("%d",&r[loop]);
    }
    int min=r[0];
    int max=r[1]-r[0];
    for(loop=1;loop<n;++loop){
        if(max<r[loop]-min){
            max=r[loop]-min;
        }
        if(min>r[loop]){
            min=r[loop];
        }
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 2516
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

char str[9][9];
char str2[9][9];
void change(){
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			str2[i][j]=str[7-j][i];
		}
	}
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			str[i][j]=str2[i][j];
		}
	}
}

int main(void){
	for(int i=0;i<8;i++){
		cin >> str[i];
	}
	cout << "90" << endl;
	change();
	for(int i=0;i<8;i++){
		cout << str[i] << endl;
	}
	cout << "180" << endl;
	change();
	for(int i=0;i<8;i++){
		cout << str[i] << endl;
	}
	cout << "270" << endl;
	change();
	for(int i=0;i<8;i++){
		cout << str[i] << endl;
	}
    return 0;
}

Measured memory_bytes: 1136
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <set> 
#include <bitset>
#include <cmath>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)

int main () {

    int n;
    cin >> n;

    string a[n];

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

    bool flag = true;
    REP(i,n-1) {
        if(a[i][a[i].size()-1] != a[i+1][0]) {
            flag  = false;
        }
    }
    REP(i,n) {
        REP(j,i) {
            if(a[i] == a[j]) {
                flag = false;
            } 
        }
    }

    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0; 
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(input())

# def LIST(): return list(map(str, input().split()))
# def LIST(): return list(input())

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

i = 1
while(1):
    i += 1
    if i * i > N:
        ans = (i - 1) * (i - 1)
        print(ans)
        os.sys.exit()

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

int main(){
  string s;cin >> s;
  int n,l;
  n = stoi(s.substr(0,2));
  l = stoi(s.substr(2,2));
  bool mmyy=false;
  bool yymm=false;
  if(1<=n&&n<=12)mmyy=true;
  if(1<=l&&l<=12)yymm=true;
  
  if(mmyy&&yymm)cout << "AMBIGUOUS" << endl;
  else if(mmyy) cout << "MMYY" << endl;
  else if(yymm) cout << "YYMM" << endl;
  else cout << "NA" <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,a[100000],i,f[100000]={0},ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	i=0;
	while(1){
		if(f[i]==1){
			puts("-1");
			return 0;
		}else if(i==1){
			printf("%d\n",ans);
			return 0;
		}
		else {
			f[i]++;
			i=a[i]-1;
			ans++;
		}
	}
	return 0;
}

Measured memory_bytes: 896
// A. 

#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	int ans = a[0] == a[1] ? a[2] : a[0];
	cout << ans << endl;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    int ans = mod;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        int cnt = 0;
        while(a%2 == 0){
            a /= 2;
            cnt++;
        }
        ans = min(ans,cnt);
    }  
    cout << ans << endl;
    return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long n;
void solve()
{
    vector < long > inp;
    long i;
    for (i=0;i<=n;i++)
        inp.push_back(0);
    for (i=1;i<=n;i++)
        cin>>inp[i];
    if (n%2)
    {
        for (i=n;i>=1;i-=2)
            cout<<inp[i]<<" ";
        for (i=2;i<n;i+=2)
        {
            if (i!=2) cout<<" ";
            cout<<inp[i];
        }
    }
    else if (n%2==0)
    {
        for (i=n;i>=2;i-=2)
            cout<<inp[i]<<" ";
        for (i=1;i<n;i+=2)
        {
            if (i!=1) cout<<" ";
            cout<<inp[i];
        }
    }
    cout<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

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

int main() {
	// your code goes here
	int n;
	long long int res=0;
	cin>>n; 
	while(n>0)
	{
		if(n%3!=0 && n%5!=0) {res=res+n;}
		n--;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3636
import static java.lang.System.out;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        double x = scan.nextDouble();
        double y = scan.nextDouble();
        double x2 = scan.nextDouble();
        double y2 = scan.nextDouble();
        double ans = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
        out.println(ans);                                                       
    }
}

Measured memory_bytes: 27984
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  t <- getl toInt
  unless (t == 0) $ do
    n <- getl toInt
    solve t <$> replicateM n (getl $ wrds toInt) >>= putStrLn
    main

solve :: Int -> [[Int]] -> String
solve t xs
  | t <= rt = "OK"
  | otherwise = show $ t - rt
  where
    rt = sum $ map (\[s,f] -> f - s) xs
    
toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)

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

  vector<int> vec(K);
  set<int> S;
  int candy;
  for (int i = 0; i < K; i++){
    cin >> vec.at(i);
    for (int j = 0; j < vec.at(i); j++){
      cin >> candy;
      S.insert(candy);
    }
  }

  int cnt = 0;
  for (int i = 1; i <= N; i++){
    if (!S.count(i)) cnt += 1;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 3592
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<double> p(N);
    for (int i = 0; i < N; i++)cin >> p[i];

    vector<vector<double>> dp(N + 1, vector<double>(N + 2, 0));
    dp[0][0] = 1.0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            dp[i + 1][j] += dp[i][j] * (1 - p[i]);
            dp[i + 1][j + 1] += dp[i][j] * p[i];
        }
    }

    //for (int i = 0; i <= N; i++) SHOW_VECTOR(dp[i]);

    double ans = 0;
    for (int i = N / 2 + 1; i <= N; i++) ans += dp[N][i];

    cout << fixed << setprecision(20) << ans << endl;

    return 0;
}
















































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

using namespace std;

int main(){
 int N;
 cin>>N;
 vector<int> d(N);

 for(int i=0;i<N;i++)cin>>d.at(i);

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

 int cnt=1;

 for(int i=0;i<N-1;i++){
  if(d.at(i)==d.at(i+1))continue;
  else cnt++;
 }
 cout<<cnt<<endl;
 return 0;
}

Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
sa=10**6
ans=0
for hi,hk in enumerate(h):
    sak=abs(t-hk*0.006-a)
    if sak<sa:
        ans=hi+1
        sa=sak
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(void)
{
  int i, j, n, a, b;
  long long int x, c[2000];
  
  scanf("%d", &x);
  
  for( i = 0; i < 2000; i++ ){
      c[i] = pow(i, 5.0);
  }
  
  for( i = 0; i < 2000; i++ ){
      for( j = 0; j <= i; j++ ){
          if( c[i] - c[j] == x ){
              printf("%d %d\n", i, j);
              return 0;
          }
      }
  }
  
  for( i = 0; i < 2000; i++ ){
      for( j = 0; j < 2000; j++ ){
          if( c[i] + c[j] == x ){
              printf("%d %d\n", i, -1*j);
              return 0;
          }
      }
  }


  return 0;
}

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

const int INF = 1001001001;

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

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


  int ans = 11111000;

  for(int i=1;i<=x[n-1];i++){
    int sum = 0;
    for(int j=0;j<n;j++){
      sum += (x[j] - i)*(x[j]-i);
    }
    ans = min(ans,sum);
  }

  cout << ans << endl;

  return 0;

}
    


Measured memory_bytes: 888
#include <iostream>

using namespace std;

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

  int min_n = 1000000, max_n = -1000000;
  long long total = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    if (a < min_n) {
      min_n = a;
    }
    if (a > max_n) {
      max_n = a;
    }
    total += a;
  }

  cout << min_n << " " << max_n << " " << total << endl;

  return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
ll MOD=1000000007;

int main(){
  ll N;
  cin >> N;
  ll ans;
  ll n10 = 10;
  ll n9  = 9;
  ll n8  = 8;
  rep(i,0,N-1){
    n10 *= 10;    n10 %= MOD;
    n9  *= 9;     n9  %= MOD;
    n8  *= 8;     n8  %= MOD;
  }
  if(N <= 2){
    cout << (N*(N-1)) << endl;
    return 0;
  }
  else{
    ans = (n10 - (n8 + 2*(n9 - n8))%MOD) % MOD;
    if(ans<0)cout << ans+MOD << endl;
    else cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 3516
def f(n):
  c=0
  while n>0:
    n%=format(n, 'b').count('1')
    c+=1
  return c

N=int(input())
X=input()
nums=[0]+[f(i) for i in range(1, N+1)] #先にi<=Nについてf(i)を求めておく

a=0 #Xの0の数
b=0 #Xの1の数

for i in range(N):
  if X[i]=='0':
    a+=1
  else:
    b+=1

#s=X%(b+1), t=X%(b-1)にする
s=0
t=0
if b>1:
  for i in range(N):
    s=(s+int(X[i])*pow(2, N-1-i, b+1))%(b+1)
    t=(t+int(X[i])*pow(2, N-1-i, b-1))%(b-1)
else:
  for i in range(N):
    s=(s+int(X[i])*pow(2, N-1-i, b+1))%(b+1)
    
"""
(1) X[i]==0の時
Xiは0が(a-1)個、1が(b+1)個となる。ここでXiに対して操作を1度行った後の数tmpは
    tmp={X%(b+1)+2^(N-1-i)%(b+1)}%(b+1)
       ={s+pow(2, N-1, b+1)}%(b+1)
となる。
tmp<(b+1)<Nなので、f(tmp)は冒頭で求めたnums[tmp]が使える。
Xiは1回操作してtmpとなり、nums[tmp]回操作して0になるので、
f(Xi)=1+nums[tmp]
で求められる。

(2) X[i]==1の時
Xiは0が(a+1)個、1が(b-1)個となる。ここでXiに対して操作を1度行った後の数tmpは
    tmp={X%(b-1)+2^(N-1-i)%(b-1)}%(b-1)
       ={t+pow(2, N-1, b-1)}%(b-1)
となる。そのため上記と同様に、
f(Xi)=1+nums[tmp]
で求められる。

ただしb=1の場合には、b-1=0となってしまうため、この場合のみ場合分けする。
具体的にはb=1の場合でX[i]=1の時は、Xi=0なので、問答無用で0を出力する。
"""
if b==1:
  for i in range(N):
    if X[i]=='0':
      tmp=(s+pow(2, N-1-i, b+1))%(b+1)
      print(nums[tmp]+1)
    else:
      print(0)
  exit()

for i in range(N):
  if X[i]=='0':
    tmp=(s+pow(2, N-1-i, b+1))%(b+1)
    print(nums[tmp]+1)
  else:
    tmp=(t-pow(2, N-1-i, b-1))%(b-1)
    print(nums[tmp]+1)


Measured memory_bytes: 12688
N = int(input())
c = 0
for i in range(1,N+1):
    r = []
    if i % 2 != 0:
        for j in range(1,i+1):
            if i % j == 0:
                r.append(j)
        if len(r) == 8:
            c+=1
print(c)

Measured memory_bytes: 2940
#include <stdio.h>

int main(void)
{
	double sum, a;
	int i;
	
	while (scanf("%lf", &a) != EOF){
		sum = a;
		
		for (i = 2; i <= 10; i++){
			if (i % 2 == 0){
				a = a * 2.0;
			}
			else {
				a = a / 3.0;
			}
			
			sum += a;
		}
		
		printf("%.8lf\n", sum);
	}
	
	return (0);
}

Measured memory_bytes: 652