akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++14

//Difficulty according to solve count during contest:
//A B C D H F E I G K L M N P S O Q R J U Z Y X T V W

#include<bits/stdc++.h>

typedef long long ll;
typedef long double lld;
using namespace std;

#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y)
#define sd3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define endl "\n"
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(c) (c.begin(),c.end())
#define LET(x, a)  __typeof(a) x(a)
#define foreach(it, v) for(LET(it, v.begin()); it != v.end(); it++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define __ freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define inf 1000000000000000001

#define tr(...) cout<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)

template<typename S, typename T>
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.fi<<", "<<p.se<<')';return out;}

template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
ll l=v.size();for(ll i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}

template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}

template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

#define int ll

int n;
vector<int> a;
vector<vector<vector<int> > > dp;
int func(int i, int j, int turn){
  if(dp[i][j][turn] != INT_MIN)
    return dp[i][j][turn];
  if(i == j){
    if(turn == 0)
      return a[i];
    else
      return -a[i];
  }
  if(turn == 0)
    dp[i][j][turn] = max(a[i] + func(i + 1, j, 1), a[j] + func(i, j - 1, 1));
  else
    dp[i][j][turn] = min(-a[i] + func(i + 1, j, 0), -a[j] + func(i, j - 1, 0));
  return dp[i][j][turn];
}
int32_t main(){
  cin >> n;
  a.resize(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  dp.resize(n, vector<vector<int> > (n, vector<int>(2, INT_MIN)));
  int ans = func(0, n - 1, 0);
  cout << ans << endl;
}


Measured memory_bytes: 495792
#include<bits/stdc++.h>
using namespace std;
stack<int>st;
queue<int>q;
vector<int>v,v1,v2,v3;
set<int>stt;
set<int>::iterator set_it;
map<string,int>mp;
//initialy map er all index er value zero thake;
//map er jonno this pointer(->) use korte hoy
//akta value dakhar jonno staristics pointer(*) use  korte hoy
// one more value print korar jonno this pointer(->) use korte hoy (must be)
map<string,int>::iterator map_it;
int a[20007];
int i,j,k,l,m,n,cnt=0,sum=0,mx=0,mn=0;
string s,s1,s2;
int main()
{
    cin>>s;
    int flag=0;
    for(i=0; i<s.size(); i++)
    {
        //cout<<s[i]<<endl;
        if(s[i]=='7')
        {
            cout<<"Yes"<<endl;
            return 0;

        }

    }

        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a; i<ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double
int main(){
  int n,m;
  cin >>n>>m;
  vector<bool> ac(n,false);
  vector<int> pe(n,0);
  ll p=0;
  ll ans=0;
  rep(i,m){
    int a;cin>>a;a--;
    string s;cin>>s;
    if(ac[a]) continue;
    if(s=="AC"){
      ac[a]=true;
      ans++;
    }else{
      pe[a]++;
    }
    
  }
  rep(i,n){
    if(ac[i]) p+=pe[i];
  }
  cout<<ans<<" "<<p<<endl;
  return 0;
}


Measured memory_bytes: 640
const main = (lines: string) => {
  const data: number = parseInt(lines, 10);
  let digits;
  let result = 0;

  for (let i = 1; i <= data; i++) {
    digits = String(i).length;
    if (digits % 2 === 1) {
      result += 1;
    }
  }

  console.log(result);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int a,b;

int main() {
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	scanf("%d%d",&a,&b);
	int c=a*b;
	if (c%2==0) printf("Even\n"); else printf("Odd\n");
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 256
suits = ["S","H","C","D"]

tables = [[False]*14 for i in range(4)]

N = int(input())

for i in range(N):
    
    clab,num = input().split()
    num = int(num)
    
    if clab == "S":
        tables[0][num] = True
    elif clab == "H":
        tables[1][num] = True
    elif clab == "C":
        tables[2][num] = True
    else:
        tables[3][num] = True
        
for i in range(4):
    for k in range(1,14):
        if tables[i][k] == False:
            print("%s %d"% (suits[i],k))


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

using namespace std;

int main(){

  long long int n, m;
  cin>>n>>m;

  long long int a[n][2], c[m][2];

  for(int i=0; i<n; i++) cin>>a[i][0]>>a[i][1];
  for(int j=0; j<m; j++) cin>>c[j][0]>>c[j][1];
  
  int ans=0;
  for(int i=0; i<n; i++){
    long long int min_dist=10000000000000000; 
    for(int j=0; j<m; j++){
      long long int sTc=abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1]);
      if(min_dist>sTc){
        ans=j+1;
      }
      min_dist=min(min_dist, sTc);
      
    }
    cout<<ans<<endl;
  }


}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{int n,net,sum;
cin>>n;
 //freopen("text.txt","r", stdin);
int a[n];
for(int i=0;i<n;i++)
{ cin>>a[i];}
int dp[n];
dp[0]=0;
dp[1]=dp[0]+abs(a[1]-a[0]);
for(int i=2;i<n;i++)
{ dp[i]=min((dp[i-2]+abs(a[i]-a[i-2])),(dp[i-1]+abs(a[i]-a[i-1])));
}
 if(n==2){cout<<(dp[1]-dp[0]); return 0; }
 else if(n<=2){ cout<<0<<endl; return 0;}
cout<<dp[n-1]<<endl;
return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int n,k;cin>>n>>k;
    string s;cin>>s;
    s[k-1]=(char)(s[k-1]+32);
    cout<<s<<endl;
}

Measured memory_bytes: 3580
////////////////////////// Author
////////////////////////// Nasim Hossain Rabbi
////////////////////////// JU-CSE28
////////////////////////// CF - imnasim3.1415
////////////////////////// UVA - imnasim3.1415
////////////////////////// Mail - imnasim3.1415@gmail.com
#include<bits/stdc++.h>
using namespace std;
#define E end()
#define B begin()
#define sz size()
#define EM empty()
#define clr clear()
#define sqr(a) (a*a)
#define mk make_pair
#define pb push_back
string en="\n";
string t="hello";
string Y="YES\n";
string N="NO\n";
#define rep(i,n) for(i=0;i<n;i++)
#define Rep(i,n) for(i=1;i<=n;i++)
#define per(i,n) for(i=n-1;i>=0;i--)
#define peR(i,n) for(i=n;i>0;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define all(cont) cont.begin(),cont.end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define pi 3.1415926535897932384626433832795
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vp(vi,x) cin>>x; vi.pb(x);
#define srch(a,x) binary_search(all(a),x)
#define LB(a,x) (lower_bound(all(a),x)-a.B)
#define UB(a,x) (upper_bound(all(a),x)-a.B)
typedef long long LL;
typedef unsigned long long ULL;
bool isprm(LL a){for(LL i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
bool isVowel(char ch){ ch=toupper(ch); if(ch=='A'||ch=='U'||ch=='I'||ch=='O'||ch=='E') return true; return false;}
int toInt(string s){int sm;stringstream ss(s);ss>>sm;return sm;}
template<typename T>inline T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<typename T>inline T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}
int main()
{
//    fast;
    LL i,j,k,n,m,l,s=0,x,y,tc=1,c=0;
    while(cin>>n)
    {
        n=((n*(n+1))/2)-n;
        cout<<n<<en;
    }
}



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

signed main(){
  int N; cin>>N;
  string S; cin>>S;
  int count1=0,count2=0,sum1=0,sum2=0;
  rep(i,0,N){
    if(S[i]=='(') count1--;
    else count1++;
    sum1=max(sum1,count1);
  }
  rep(i,0,N){
    if(S[N-1-i]==')') count2--;
    else count2++;
    sum2=max(sum2,count2);
  }
  rep(i,0,sum1) cout<<'(';
  cout<<S;
  rep(i,0,sum2) cout<<')';
  }


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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 300200;
const long long Q = 100000001;
const long long mod = 1e9 + 7;
const long long MAGIC = 30;

using namespace std;

int n;
int a[N];

void solve()
{
        cin >> n;
        vector < int > v;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                if(a[i] > a[i - 1] + 1){
                        cout << -1 << "\n";
                        return;
                }
        }
        if(a[1] > 0){
                cout << -1 << "\n";
                return;
        }
        long long ans = 0, cur = 0;
        for(int i = n; i >= 1; i--){
                if(cur != a[i]){
                        ans += a[i];
                }
                cur = a[i] - 1;
        }
        cout << ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int time (int a, int b)
{
    int temp=a;
    while (a<b)
    {
        a+=temp;
    }
    return a-b;
}
int main()
{
    int n,ans=0;
    cin>>n;
    int c[n], s[n], f[n];
    for (int i=1; i<n; i++) cin>>c[i]>>s[i]>>f[i];
    for (int i=1; i<n; i++)
    {
        ans=s[i];
        for (int j=i; j<n; j++)
        {
            ans+=c[j];
            if (j<n-1)
            {
                if (s[j+1]>ans) ans+=(s[j+1]-ans);
                else ans+=time(f[j+1],ans);
            }
        }
        cout<<ans<<"\n";
    }
    cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;

ll p;
ll power(ll a,ll b){return b?power(a*a%p,b/2)*(b%2?a:1)%p:1;}


int main(){FIN

    ll n;cin>>n>>p;
    string s;cin>>s;
    map<ll,ll> mp;
    mp[0]++;

    ll dig=0, count=0, ans=0;
    FORR(i,s.size()-1, 0){
        
        if(p==2 || p==5){
            if ((s[i]-'0') % p == 0){
                ans+=(i+1);
            }
            // cout<<ans<<endl;
        }

        else{
            if(i==s.size()-1) dig=s[i]-'0';
            else dig+= (s[i]-'0')*power(10,count);
            
            dig%=p;
            mp[dig]++;
            count++;
        }
        // cout<<dig<<endl;
    }
    if(p==2||p==5){
        cout<<ans<<endl;
        return 0;
    }


    else{
        ll as = 0;
        for(auto p:mp){
            as += p.second * (p.second-1) / 2;
        }
        cout<<as<<endl;
    }

    return 0;
}

Measured memory_bytes: 1044
package main

import "fmt"

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	if a > 2*c {
		a = 2 * c
	}
	if b > 2*c {
		b = 2 * c
	}

	ans := 0
	if a+b < 2*c {
		ans = a*x + b*y
	} else {
		for {
			if x > 0 && y > 0 {
				ans += 2 * c
			} else if x > 0 {
				ans += a
			} else if y > 0 {
				ans += b
			} else {
				break
			}
			x--
			y--
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000000
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi 3.14159
ll power(ll a,int n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return power(a*a,n/2);
	else
	  return a*power(a*a,n/2);    
}
int main(){
FASTIO
double r;
cin>>r;
cout<<2*pi*r;
return 0;
}


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

const int ac = 1e6 + 6;
int A[ac][13];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int n = s.size();
	A[0][0] = 1;
	int mod = 1e9 + 7;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			if (s[i] == '?')
			{
				for (int k = 0; k < 10; k++)
				{
					A[i + 1][(j * 10 + k) % 13] += A[i][j];
					A[i + 1][(j * 10 + k) % 13] %= mod;
				}
			}
			else 
			{
				A[i + 1][(j * 10 + (s[i] - '0')) % 13] += A[i][j];
				A[i + 1][(j * 10 + (s[i] - '0')) % 13] %= mod;
			}
		}
	}
	cout << A[n][5] << '\n';
}


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

int main() {
	
	int x, y;
	
	while (1) {
		cin >> x >> y;
		if (!x && !y) {
			break;
		}
		if (x > y) {
			cout << y << ' ' << x << endl;
		}
		else {
			cout << x << ' ' << y << endl;
		}
	}


	return 0;
}


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

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

    vector<int64_t> a(9);
    for (int i = 1; i <= 9; ++i) {
        a[i - 1] = i;
    }

    for (;;) {
        if (K < a.size()) {
            cout << a[K - 1] << endl;
            return 0;
        }

        K -= a.size();

        vector<int64_t> old;
        swap(old, a);

        for (auto x : old) {
            for (int i = -1; i <= 1; ++i) {
                int d = x % 10 + i;
                if (d < 0 || 9 < d) {
                    continue;
                }

                int64_t nx = x * 10 + d;
                a.push_back(nx);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1712
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    int dp[s.length()+1][t.length()+1];
    for(int i=0;i<(int)s.size()+1;i++){
        for(int j=0;j<(int)t.size()+1;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(s[i-1]==t[j-1]){
              //  cout<<i<<" "<<j<<endl;
              //  cout<<s[i-1]<<" "<<t[j-1]<<endl;
                dp[i][j]=dp[i-1][j-1]+1;
               // cout<<"増えた"<<endl;
            }else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    int num = dp[s.size()][t.size()];
  //  cout<<num<<endl;
  int Num=num;
    vector<char> reg(num);
    int i=s.size();
    int j=t.size();
    while(i>0&&j>0){
     //   cout<<i<<" "<<j<<endl;
        if(s[i-1]==t[j-1]){
            reg[num-1]=s[i-1];
        //    cout<<"同じ"<<" "<<s[i-1]<<endl;
            num--;
            i--;
            j--;
        }else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }else{
            j--;
        }
    }
    //cout<<"わふー"<<endl;
    //cout<<reg[0]<<reg[1]<<endl;
    for(int l=0;l<Num;l++){
        cout<<reg[l];
      //  cout<<"出力"<<endl;
    }
    cout<<endl;
}

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int k;cin >> k;
    int a,b;cin >> a >> b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
const int mod = 998244353;

int main()
{
    ll n, x, m;
    cin >> n >> x >> m;
    vector<int> id(m,-1);
    vector<int> a;
    int len = 0;
    ll tot = 0;
    while (id[x] == -1) {
        a.push_back(x);
        id[x] = len;
        len++;
        tot += x;
        x = (x*x)%m;
    }
    int c = len-id[x];
    ll s = 0;
    for (int i = id[x]; i < len; i++) {
        s += a[i];
    }
    ll ans = 0;
    if (n <= len) {
        rep(i,n) ans += a[i];
    } else {
        ans += tot;
        n -= len;
        ans += s*(n/c);
        n %= c;
        rep(i, n) ans += a[id[x]+i];
    }
    cout << ans << endl;
    return 0;
}

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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

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

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

int main(){
    int H, W; cin >> H >> W;
    int Ch, Cw; cin >> Ch >> Cw;
    Ch--, Cw--;
    int Dh, Dw; cin >> Dh >> Dw;
    Dh--, Dw--;
    vector<string> field(H);
    for(int i=0; i<H; i++) cin >> field[i];

    deque<pii> dq;
    vii dist(H, vi(W, INF));
    dist[Ch][Cw]=0;
    dq.push_front({Ch, Cw});
    while(!dq.empty()){
        int x, y;
        tie(x, y)=dq.front();
        dq.pop_front();
        for(int i=0; i<24; i++){
            int nx, ny;
            nx=x+dx[i], ny=y+dy[i];
            if(nx<0 || nx>=H || ny<0 || ny>=W) continue;
            if(field[nx][ny] == '#') continue;
            if(i < 4){
                if(dist[nx][ny] <= dist[x][y]) continue;
                dist[nx][ny]=dist[x][y];
                dq.push_front({nx, ny});
            }
            else{
                if(dist[nx][ny] <= dist[x][y]+1) continue;
                dist[nx][ny]=dist[x][y]+1;
                dq.push_back({nx, ny});
            }
        }
    }
    if(dist[Dh][Dw] != INF) cout << dist[Dh][Dw] << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 9488
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	//vector<int> size;
    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) {
			par[i] = i;
		}
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		//size[rx]=size[rx]+size[ry];
		//size[ry]=size[rx];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

vector<Pi> ab;
int ans[200100]={};
int main(){
	int n,k,l;
	cin>>n>>k>>l;
	UnionFind road(n);
	UnionFind train(n);
	REP(i,k){
		int p,q;
		cin>>p>>q;
		p--,q--;
		road.unite(p,q);
	}
	REP(j,l){
		int r,s;
		cin>>r>>s;
		r--,s--;
		train.unite(r,s);
	}
	map<pair<int,int>,int> m;
	REP(j,n){
		pair<int,int> t1=make_pair(road.root(j),train.root(j));
		int tmp=m[t1];
		m[t1]=tmp+1;
	}
	REP(j,n){
		pair<int,int> t1=make_pair(road.root(j),train.root(j));
		cout<<m[t1]<<" ";
	}
	cout<<endl;
	return 0;
}
	

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N;
    cin >> N;
    cout << (N / 2) + (N % 2 == 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const ll INF = 4e18;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    int r[R];
    rep(i, 0, R) {
        cin >> r[i];
        r[i]--;
    }

    ll dist[N][N];
    rep(i, 0, N) {
        rep(j, 0, N) {
            dist[i][j] = INF;
        }
        dist[i][i] = 0;
    }

    rep(i, 0, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        dist[a][b] = c;
        dist[b][a] = c;
    }

    rep(k, 0, N) {
        rep(i, 0, N) {
            rep(j, 0, N) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    sort(r, r + R);
    ll ans = INF;
    do {
        ll d = 0;
        rep(i, 0, R - 1) {
            d += dist[r[i]][r[i + 1]];
        }
        ans = min(ans, d);
    } while (next_permutation(r, r + R));

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


Measured memory_bytes: 512
n, m = map(int, input().split(' '))
dp = [10**9 for _ in range(2**n)]
dp[0] = 0
for i in range(m):
    a, b = map(int, input().split(' '))
    c = list(map(int, input().split(' ')))
    num = 0
    for j in range(b):
        num += 1 << (c[j]-1)
    for s in range(2**n):
        if dp[s|num] >= dp[s] + a:
            dp[s|num] = dp[s] + a
if dp[-1] == 10**9:
    print(-1)
else:
    print(dp[-1])

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    char t = '0';
    int  count = 0;
    rep(i, 0, N){
        char s;
        cin >> s;
        if(t != s){
            t = s;
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, c;
    while (cin >> a >> b >> c) {
        if (a + b + c >= 22) cout << "bust" << endl;
        else cout << "win" << endl;
    }
}


















Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner o = new Scanner(System.in);
        String s1 = o.nextLine();
        String s2 = o.nextLine();
        boolean ok = true;
        for ( int i = 0 ; i < s1.length() ; i++ )
        {
            if ( s1.charAt(i) != s2.charAt(i) )
            {
                ok = false;
                break;
            }
        }

        if(!ok){
            System.out.println("No");
        }
        else{
            System.out.println("Yes");
        }
        
    }
}

Measured memory_bytes: 26976
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

constexpr int MOD = int(1e9) + 7;

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

    i64 N, M;
    bool ng[100010] {};

    read(N, M);
    vector<i64> dp(N + 5, 0);
    rep(i, M) {
        int a; read(a);
        ng[a] = true;
    }

    dp[0] = 1;
    reps(i, 0, N) {
        if (!ng[i]) {
            (dp[i + 1] += dp[i]) %= MOD;
            (dp[i + 2] += dp[i]) %= MOD;
        }
    }

    print(dp[N]);

    return 0;
}


Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in);) {
            int n = scanner.nextInt();
            int ac = 0;
            int wa = 0;
            int tle = 0;
            int re = 0;

            for (int i = 0; i < n; i++) {
                switch (scanner.next()) {
                    case "AC":
                        ac++;
                        break;
                    case "WA":
                        wa++;
                        break;
                    case "TLE":
                        tle++;
                        break;
                    case "RE":
                        re++;
                        break;
                    default:
                        break;
                }
            }
            StringBuilder sb = new StringBuilder();
            sb.append("AC x " + ac + "\n");
            sb.append("WA x " + wa + "\n");
            sb.append("TLE x " + tle + "\n");
            sb.append("RE x " + re + "\n");
            System.out.println(sb.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 59204
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    ll A,B,K;
    cin>>A>>B>>K;
    if(A>=K){
        A-=K;
    }else{
        B-=(K-A);
        if(B<0){
            B=0;
        }
        A=0;
    }
    cout<<A<<" "<<B<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll h, w, d, t;
char c[4] = {'R', 'Y', 'G', 'B'};
int main() {
    cin >> h >> w >> d;
    if(d % 2 == 1){
        REP(i, h){
            REP(j, w){
                cout << ((i + j) % 2 == 0 ? 'R' : 'G');
            }
            cout << endl;
        }
        return 0;
    }
    REP(i, h){
        REP(j, w){
            ll x, y;
            if((i + j) % 2 == 0){
                x = (i - j) / 2;
                y = (i + j) / 2;
            }
            else {
                x = (i - 1 - j) / 2;
                y = (i - 1 + j) / 2;
            }
            ll s = ((x + d * 100000) / (d / 2) + 100000) % 2;
            ll t = ((y + d * 100000) / (d / 2) + 100000) % 2;
           cout << c[s * 2 + t];
        }
        cout << endl;
    }
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define MAX 1000000
#define MOD 1e9
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define ll long long
#define endl '\n'
using namespace std;
/* ----------------------------------------------------------------------------------- */

#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define rep(i, a, n) for (int i = a; i < n; i++)
#define REP(i, a, n) for (int i = a; i <= n; i++)
#define inputArray(a,n) rep(i, 0, n) cin >> a[i];
#define copyArray(a,temp,n) rep(i, 0, n) temp[i]=a[i];
#define printArray(a,n) rep(i, 0, n) cout << a[i] << " "; cout << endl;

/* ----------------------------------------------------------------------------------- */

#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)

#define dbgA2(A, n, m) {cout<<"--> "<<#A<<" = \n";rep(i, 0, n){rep(j, 0, n){cout<<A[i][j]<<" ";}cout<<"\n";}cout<<"\n";}
#define dbgA(A, n) {cout<<" --> "<<#A<<" = (";rep(i, 0, n)cout<<A[i]<<" ";cout<<")\n";}
#define dbg(args...) {string sss(#args);sss+=',';cout<<" --> ";debugger::call(all(sss), args);cout<<"\n";}

/* ----------------------------------------------------------------------------------- */

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }

struct debugger {
	typedef string::iterator si;
	static void call(si it, si ed) {}
	template<typename T, typename ... aT>
	static void call(si it, si ed, T a, aT... rest) {
		string b;
		for(; *it!=','; ++it)
			if(*it!=' ')
				b+=*it;
		cout << b << "=" << a << " ";
		call(++it, ed, rest...);
	}
};

/* ----------------------------------------------------------------------------------- */

void solve() {
	int n;
	cin >> n;
	int arr[n];
	bool isApproved = true;

	for (int i = 0; i < n; i++) {
		cin >> arr[i];
		if(arr[i] % 2 == 0) {
			if(arr[i] % 3 != 0 && arr[i] % 5 != 0) {
				isApproved = false;
			}
		}
	}

	if(isApproved) {
		cout << "APPROVED\n";
	} else {
		cout << "DENIED\n";
	}
}

int main() {
	solve();

	// __test {
	// 	solve();
	// }
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

const double PI=3.14159265358979323846;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(a) memset(a, 0, sizeof(a))

#define RAD(d) (PI * (d) / 180)
#define DEG(r) (180.0 * (r) / PI)

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

template<class T> void dump(const vector<T> &v)
{
	REP(i, SZ(v)-1){ cout << v[i] << " "; }
	cout << v[SZ(v)-1] << endl;
}

template<class T> void dump(int w, int h, const vector<T> &v)
{
	REP(j, h){
		REP(i, w-1){ cout << v[j * w + i] << " "; }
		cout << v[j * w + w-1] << endl;
	}
}

template<class T> T accumulate(const vector<T> &v)
{
	T sum = 0;
	REP(i, SZ(v)){ sum += v[i]; }
	return sum;
}

template<class T> struct Matrix
{
	T w, h;
	vector<T> A;
	Matrix(T w_, T h_) : w(w_), h(h_), A(w * h) {}
	T get(T x, T y) const { return A[y * w + x]; }
};

template<class T> void input(Matrix<T> &m)
{
	REP(j, m.h){
		REP(i, m.w){
			cin >> m.A[j * m.w + i];
		}
	}
}

template<class T> Matrix<T> prod(const Matrix<T> &a, const Matrix<T> &b)
{
	Matrix<T> m(b.w, a.h);

	REP(j, m.h){
		REP(i, m.w){
			ll c = 0;
			REP(k, a.w){
				c += a.A[j * a.w + k] * b.A[k * b.w + i];
			}
			m.A[j * m.w + i] = c;
		}
	}

	return m;
}

void dump(const Matrix<ll> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%lld ", m.A[j * m.w + i]); }
		printf("%lld\n", m.A[j * m.w + m.w-1]);
	}
}

void dump(const Matrix<double> &m)
{
	REP(j, m.h){
		REP(i, m.w-1){ printf("%f ", m.A[j * m.w + i]); }
		printf("%f\n", m.A[j * m.w + m.w-1]);
	}
}

string &to_upper(string &s)
{
	REP(i, s.length()){
		if('a' <= s[i] && s[i] <= 'z'){
			s[i] -= 32;
		}
	}

	return s;
}

string &to_lower(string &s)
{
	REP(i, s.length()){
		if('A' <= s[i] && s[i] <= 'Z'){
			s[i] += 32;
		}
	}

	return s;
}

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

		if(n == 0)
			break;

		vector<double> s(n);
		REP(i, n){
			cin >> s[i];
		}

		double m = accumulate(s) / n;

		double alpha = 0;
		REP(i, n){
			alpha += pow(s[i] - m, 2);
		}
		alpha /= n;
		alpha = sqrt(alpha);

		printf("%.8f\n", alpha);
	}
	
	return 0;
}



Measured memory_bytes: 3224
P = [1 for _ in range(100)]
P[0]=0
P[1]=0
for i in range(2,11):
    for j in range(i*i,100,i):
        P[j] = 0
Q = []
for i in range(2,100):
    if P[i]==1:
        Q.append(i)
C = {q:0 for q in Q}
N = int(input())
for i in range(2,N+1):
    x = i
    for q in Q:
        while x%q==0:
            x = x//q
            C[q] += 1
D = {2:0,4:0,14:0,24:0,74:0}
for q in Q:
    if C[q]>=2:
        D[2] += 1
    if C[q]>=4:
        D[4] += 1
    if C[q]>=14:
        D[14] += 1
    if C[q]>=24:
        D[24] += 1
    if C[q]>=74:
        D[74] += 1
cnt = D[74]
cnt += (D[2]-D[24])*D[24]+(D[24]*(D[24]-1))
cnt += (D[4]-D[14])*D[14]+(D[14]*(D[14]-1))
cnt += (D[2]-D[4])*(D[4]*(D[4]-1))//2+(D[4]*(D[4]-1)*(D[4]-2))//2
print(cnt)

Measured memory_bytes: 63652
using System;
using System.Linq;

namespace E
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var filterMax = (int)Math.Sqrt(A.Max());
            var filter = new bool[filterMax + 1];
            for (int i = 0; i < filterMax + 1; i++) filter[i] = true;
            var filterCount = new int[A.Max() + 1];

            for (int i = 0; i < N; i++)
            {
                if (A[i] > filterMax) filterCount[A[i]]++;
            }

            for (int i = 2; i <= filterMax; i++)
            {
                if (!filter[i]) continue;

                for (int j = 0; j < N; j++)
                {
                    if ((A[j] % i) == 0)
                    {
                        filterCount[i]++;
                        if (filterMax < (A[j] / i))
                            filterCount[A[j] / i]++;
                    }
                }

                for (int k = i; k <= filterMax; k += i) filter[k] = false;
            }


            if (filterCount.Max() == N) Console.WriteLine("not coprime");
            else if (filterCount.Max() > 1) Console.WriteLine("setwise coprime");
            else Console.WriteLine("pairwise coprime");
        }
    }
}


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

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

    vector<int> east(n+2);
    vector<int> west(n+2);
    for(int i=1; i<=n; i++){
        if(s[i-1] == 'E') east[i] = 1;
        if(s[i-1] == 'W') west[i] = 1;
    }
    for(int i=1; i<n+2; i++){
        east[i] += east[i-1];
        west[i] += west[i-1];
    }

    int ans = n;// INF
    for(int i=1; i<=n; i++){// position of the leader
        int number = west[i-1] + east[n+1] - east[i];
        if(number < ans) ans = number;
        // cout << i << " " << west[i-1] << " " << east[n+1] - east[i] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
typedef long long ll;

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

    int n;
    cin >> n;
    if(n<=111)
        cout << 111;
    else if(n<=222)
        cout << 222;
    else if(n<=333)
        cout << 333;
    else if(n<=444)
        cout << 444;
    else if(n<=555)
        cout << 555;
    else if(n<=666)
        cout << 666;
    else if(n<=777)
        cout << 777;
    else if(n<=888)
        cout << 888;
    else if(n<=999)
        cout << 999;
}

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

int main(){
    ll N,K; cin>>N>>K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++){
        cin>>A[i];
    }
    
    if(N==K){
        cout<<1<<endl;
        return 0;
    }else if(K==2){
        cout<<N-1<<endl;
        return 0;
    }else{
        ll ans=N/(K-1);
        if(N%(K-1)>1) ans++;
        cout<<ans<<endl;
    }
}
    

Measured memory_bytes: 1024
import sys
read = sys.stdin.read
from operator import itemgetter
from copy import deepcopy
from collections import deque
def main():
    def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x])
            return par[x]

    def unite(x, y):
        x = find(x)
        y = find(y)
        if x == y:
            return False
        else:
            if par[x] > par[y]:
                x, y = y, x
            par[x] += par[y]
            par[y] = x
            return True
    def same(x, y):
        return find(x) == find(y)
    def size(x):
        return -par[find(x)]
    def members(x):
        root = find(x)
        return [i for i in range(n) if find(i) == root]
    def roots():
        return [i for i, x in enumerate(par) if x < 0]

    # input
    n = int(input())
    m = map(int, read().split())
    # inputされたノード座標のリストをｘ座標とｙ座標それぞれでソート。
    mm = zip(m, m)
    cnt = 0
    nodes = []
    nodes_a = nodes.append
    for a, b in mm:
        # nodes_a(x座標、y座標、ノード名) ※ノード名は0origin。union-findを使うため。
        nodes_a((a, b, cnt))
        cnt += 1
    nodes.sort(key=itemgetter(0))
    nodes_y = deepcopy(nodes)
    nodes_y.sort(key=itemgetter(1))
    # ノード座標リストからｘ軸とｙ軸それぞれで「隣接するノードをむすぶ辺」のリストをedgesに格納。
    edges = []
    for i1 in range(n - 1):
        # 辺のコスト、端のノード２つ
        edges.append((nodes[i1+1][0] - nodes[i1][0], nodes[i1][2], nodes[i1+1][2]))
        edges.append((nodes_y[i1+1][1] - nodes_y[i1][1], nodes_y[i1][2], nodes_y[i1+1][2]))
    # 「コストが小さい順」でソート
    edges.sort(key=itemgetter(0))
    # union-findをつかってクラスカル法をする。
    par = [-1] * n  # union-find用のデータ初期化
    edges = deque(edges)  # edgesを左から１つずつpopするのでdequeに変換。
    r = 0  # rに「森に加えた辺のコスト」を加算していく
    while edges:
        e = edges.popleft()
        if not same(e[1], e[2]):
            r += e[0]
            unite(e[1], e[2])
    print(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 141268
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
	# if(k%i==0):
	score=i
	tmp=0
	while(score<k):
		score=score*2
		tmp=tmp+1
	ans=ans+pow(0.5,tmp)
ans=ans/n
print(ans)


Measured memory_bytes: 9228
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


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

    string s = [&] {
        int i = n % 10;
        switch (i) {
            case 2:
            case 4:
            case 5:
            case 7:
            case 9:
                return "hon";
            case 0:
            case 1:
            case 6:
            case 8:
                return "pon";
            default:
                return "bon";


        }
    }();

    cout << s << endl;
}


Measured memory_bytes: 3596
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;
using LD = long double;

LL N, M;

int main(void)
{
	cin >> N >> M;
	LL lop = (N - M) * 100 + M * 1900;
	LD p = 1;
	for (int i = 0; i < M; ++i)p /= 2;
	LD ans = 0;
	LD pp = 1;
	LD pf = 1;
	for (int i = 1; i < 1000000; ++i) {
		pp *= p;
		ans += lop * i * p * pf;
		pf *= (1 - p);
	}
	LL answer = round(ans);
	cout << answer << endl;
	return 0;
}


Measured memory_bytes: 384
# AOJ 0113: Period
# Python3 2018.6.20 bal4u

while True:
	try: p, q = list(map(int, input().split()))
	except: break
	rr = [-1]*q
	rr[p] = 0
	ans = ''
	for k in range(1, q):
		p *= 10
		ans += str(p // q)
		r = p % q
		if r == 0 or rr[r] >= 0:
			print(ans)
			if rr[r] >= 0: print(*[' ']*rr[r], *['^']*(k-rr[r]), sep='')
			break
		rr[r], p = k, r



Measured memory_bytes: 21436