akhauriyash/Code-Regression huggingface dataset:
x,y=map(int,input().split())
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]
if x in A and y in A:
  print("Yes")
elif x in B and y in B:
  print("Yes")
elif x == y:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
N = int(input())
a = [0]*N
tmp = input().split()
for i in range(N):
    a[i] = int(tmp[i])

a.sort(reverse=True)
A = B = 0


for i in range(0,N//2):
    A += a[2*i]
    B += a[2*i+1]
if N%2 == 1:
    A += a[N-1]

print(A-B)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
#define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb(x) push_back(x)
#define eb(x) emplace_back(x)
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())

int main(){
	boost
	ll n,m,x,y,f,g,h,i;
	cin>>n>>m>>x>>y;
	ll xa[n],ya[m];
	fo(i,0,n){
	    cin>>xa[i];
	}
	fo(i,0,m){
	    cin>>ya[i];
	}
	sort(xa,xa+n);
	sort(ya,ya+m);
	for(i=x+1;i<=y;i++){
	    f=0;g=0;h=0;
	    if(xa[n-1] < i){
	        f=1;
	    }
	    if(ya[0] >= i){
	        g=1;
	    }
	    if(f && g){
	        h=1;
	        break;
	    }
	}
	if(h){
	    cout<<"No War\n";
	}
	else{
	    cout<<"War\n";
	}
	return 0;
}

Measured memory_bytes: 256
// A.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	char cnt[256] = {};
	string s;
	cin >> s;
	for (char c : s) {
		cnt[c] += 1;
	}
	bool ok = true;
	for (int i = 'A'; i <= 'Z'; ++i) {
		if (cnt[i] != 0 && cnt[i] != 2) {
			ok = false;
		}
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [int(x) for x in input().split()]
T = int(input())
Q = [int(x) for x in input().split()]

c = 0

def seach(A, n, key):
    i = 0
    A = A + [key]
    while A[i] != key:
        i += 1
    return i != n

for q in Q:
    if seach(S, N, q):
        c += 1
        
print(c)


Measured memory_bytes: 6552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int main(){
	int a;
	cin >> a;
	cout << a+a*a+a*a*a << endl;

	return 0;
}

Measured memory_bytes: 3584
/*+lmake
 * STD = c++14
 * DEFINE += WAAUTOMATON
 */
#include <bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;

#ifdef WAAUTOMATON
#define debug(args...)                                                                             \
    {                                                                                              \
        dbg, args;                                                                                 \
        cerr << endl;                                                                              \
    }
#define massert(x) assert(x)
#else
#define debug(args...) // Just strip off all debug tokens
#define massert(x)
#endif

struct debugger
{
    template<typename T> debugger& operator , (const T& v)
    {    
        cerr<<v<<" ";    
        return *this;    
    }
} dbg;
map<ULL,pair<ULL,int>> x;
int p[10000],pcnt;
void init()
{
	for(int i=2; i<=2155; ++i) {
		bool flag=true;
		for(int j=1; j<=pcnt; ++j) {
			if (i%p[j]==0) {
				flag=false;
				break;
			}
		}
		if (flag) {
			p[++pcnt]=i;
		}
	}
}
ULL getHash(int* f,int* ff,int fcnt)
{
	ULL ans=0;
	for(int i=1; i<=fcnt; ++i) {
		ans+=f[i];
		ans*=1007;
		ans+=ff[i];
		ans*=1007;
	}
	return ans;
}
void solve(long long N, vector<long long> s){
	init();
	debug(pcnt);
	int ans=0;
	bool flag=false;
	for(auto i:s) {
		LL bak=i;
		static int f[100],ff[100];
		int fcnt=0;
		for(int j=1; j<=pcnt; ++j) {
			if (i%p[j]==0) {
				f[++fcnt]=j;
				int cnt=0;
				while(i%p[j]==0) {
					++cnt;
					i/=p[j];
				}
				ff[fcnt]=cnt%3;
				if (ff[fcnt]==0) --fcnt;
			}
		}
		if (i>1) {
			LL t=sqrtl(i);
			if (t*t==i) {
				f[++fcnt]=t;
				ff[fcnt]=2;
			} else if ((t+1)*(t+1)==i) {
				f[++fcnt]=t+1;
				ff[fcnt]=2;
			} else if ((t-1)*(t-1)==i) {
				f[++fcnt]=t-1;
				ff[fcnt]=2;
			}else {
				f[++fcnt]=i;
				ff[fcnt]=1;
			}
		}
		bool flag2=true;
		for(int j=1; j<=fcnt; ++j) {
			if (ff[j]>0) {
				flag2=false;
				break;
			}
		}
		if (flag2) {
			flag=true;
			continue;
		}
		ULL hnow=getHash(f,ff,fcnt);
		for(int j=1; j<=fcnt; ++j) {
			massert(ff[j]>0);
			ff[j]=3-ff[j];
		}
		ULL to=getHash(f,ff,fcnt);
		//debug(bak,hnow,to);
		if (x.count(hnow)==0) {
			x[hnow]=make_pair(to,1);	
		} else {
			if (x[hnow].first!=to) {
				debug(hnow,x[hnow].first,to);
			}
			massert(x[hnow].first==to);
			x[hnow].second++;
		}
	} 
	int cnt=0;
	for(auto i:x) {
		cnt+=i.second.second;
	}
	debug(cnt);
	int ans2=0;
	for(auto i:x) {
		ULL a=i.first,b=i.second.first;
		int cnt=i.second.second;
		if (x.count(b)==0) {
			ans+=cnt;
		} else if (x[b].second<cnt) {
			ans+=cnt;
			//x.erase(b);
			//debug(a,b);
		} else if (x[b].second==cnt){
			ans2+=cnt;

		}
	}
	if (flag) ++ans;
	ans+=ans2/2;
	cout<<ans<<endl;
}

int main(){	
#ifdef WAAUTOMATON
	freopen("in.txt","r",stdin);
#endif
	long long N;
	scanf("%lld",&N);
	vector<long long> s(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&s[i]);
	}
	solve(N, s);
	return 0;
}



Measured memory_bytes: 9600
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int z=0;
		if(A>=B){
			z+=A;
			A--;
		}
		else{
			z+=B;
			B--;
		}
		if(A>=B){
			z+=A;
			A--;
		}
		else{
			z+=B;
			B--;
		}
		System.out.println(z);
	}
}

Measured memory_bytes: 23636
PROGRAM ATCODER
implicit none
integer :: n, i, j
integer, allocatable :: a(:), sum(:)
  
read(*,*) n
allocate(a(n),sum(201))
read(*,*)(a(i), i=1,n)

sum = 0
do i = 101+minval(a), 101+maxval(a)
	do j = 1, n
        sum(i) = sum(i) + ((i-101)-a(j))**2
	end do
end do
	
write(*,'(i0)') minval(sum(101+minval(a):101+maxval(a)))

END PROGRAM ATCODER

Measured memory_bytes: 256
// ワーシャルフロイド的に辺追加

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
    int i,j;
    int n,k;
    while(1){
        cin>>n>>k;
        if(n==0) break;
        VVI v(n,VI(n,inf));
        for(i=0;i<n;i++) v[i][i]=0;
        while(k--){
            int t;
            cin>>t;
            if(t){
                int c,d,e;
                cin>>c>>d>>e;
                c--; d--;
                for(i=0;i<n;i++){
                    for(j=0;j<n;j++){
                        v[i][j]=min({v[i][j],v[i][c]+v[d][j]+e,v[i][d]+v[c][j]+e});
                    }
                }
            }
            else {
                int a,b;
                cin>>a>>b;
                a--; b--;
                cout<<((v[a][b]==inf)? -1:v[a][b])<<endl;
            }
        }
    }

}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int a[n];
	zip(i, 0, n)
	{
		cin >> a[i];

	}
	zip(i, 0, n)
	{
		if (a[i] % 2 == 0 && (a[i] % 3 != 0 && a[i] % 5 != 0))
		{
			cout << "DENIED" << en;
			return 0;
		}
	}
	cout << "APPROVED" << en;



	return 0;
}



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

int main(){
    string s; cin >> s;
    int n = s.size();
    bool flag1 = true;
    for(int i=0;i<n/2;i++){
        if(s[i]!=s[n-1-i]){
            flag1 = false;
            break;
        }
    }
    string a = s.substr(0,(n-1)/2);
    int m = a.size();
    bool flag2 = true;
    for(int i=0;i<m/2;i++){
        if(a[i]!=a[m-1-i]){
            flag2 = false;
            break;
        }
    }
    if(flag1 && flag2){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}



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

using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mkp make_pair

#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

int mmul(ll p,ll q,int m){ //O(1)?
    ll lp=p,lq=q; return ((lp%m)*(lq%m))%m;
}

int mpow(ll x,ll n,int m){ //O(logN)
    ll res=x,ans=1;
    while(n!=0){
        if(n%2==0){ res = mmul(res,res,m);n>>=1;
        }else{      ans = mmul(ans,res,m);--n;}}return ans;}


int mdiv(ll p,ll q,int m){ //O(logMOD)
    return mmul(p,mpow(q,m-2,m),m);
}

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int n,mxbit=0;
    cin >>n;
    vector<ll> a(n);
    vector<int> bc(64,0);
    map<ll,int>app;

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

        //app[a[i]]++;

        int p=0;
        ll tmp=a[i];

        while (tmp>0){
            if(tmp%2==1){
                bc[p]++;

                mxbit=max(mxbit,p);
            }

            tmp/=2;
            ++p;
        }
    }

    /*
    for (int i = 0; i <= mxbit; i++)
    {
        cout << bc[i]<<" ";
    }
    puts("\n");
    */


    for (int i = 0; i < n; i++){
        ll tmp=a[i];
        int p=0;

        bool f=false;
        for(int p=0;p <= mxbit;++p){
            
            if(tmp%2==0 || f){
                ans =(ans + mmul(bc[p], mpow(2,p,MOD) ,MOD) %MOD);
            }else{
                ans =(ans + mmul(n-bc[p], mpow(2,p,MOD),MOD) %MOD);
            }
            if(tmp<=0)f=true;
            else tmp/=2;
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << mdiv(ans,2,MOD) << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
string s;
bool ans=false;
signed main(){
    cin>>s;
    int l=s.size();
    rep(i,l-1){
        if(s.substr(i,2)=="AC")ans=true;
    }
    if(ans)puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <complex>
#include <iostream>
#include <vector>
#include <utility>
#define X real()
#define Y imag()
#define EPS 1e-10
using namespace std;
typedef complex<double> P;
typedef pair<P, P> L;
typedef vector<P> Poly;

double cross(P a, P b){
  return a.X*b.Y-a.Y*b.X;
}

int is_convex(Poly p){
  int n = p.size();
  if(cross(p[0]-p[n-1],p[n-2]-p[n-1]) < 0) return 0;
  for(int i = 1; i < n-1; ++i){
    if(cross(p[i+1]-p[i],p[i-1]-p[i]) < 0) return 0;
  }
  return 1;
}

int main(){
  int n;
  cin >> n;
  double x, y;
  Poly p(n);
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    p[i] = P(x,y);
  }
  cout << is_convex(p) << endl;
  return 0;
}

Measured memory_bytes: 3212
n = int(input())
ab = []
for i in range(n):
    ab.append(list(map(int, input().split())))
ans = 0
for i in range(n-1,-1,-1):
    x = (ab[i][1] - (ab[i][0]+ans)%ab[i][1])%ab[i][1]
    #print(x)
    ans += x

print(ans)



Measured memory_bytes: 60376
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

class UnionFind {
public:
  UnionFind(int n) : par(n, -1), rnk(n, 0), cnt(n, 1), _size(n) {}

  bool same(int x, int y) {
    return root(x) == root(y);
  }
  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;

    --_size;

    if (rnk[x] < rnk[y]) { swap(x, y); }
    par[y] = x;
    cnt[x] += cnt[y];
    if (rnk[x] == rnk[y]) { ++rnk[x]; }
  }
  int root(int x) {
    if (par[x] < 0) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }
  int count(int x) {
    return cnt[root(x)];
  }
  int size() {
    return _size;
  }

private:
  vector<int> par;
  vector<int> rnk;
  vector<int> cnt; // The number of vertices in each connected components.
  int _size; // The number of connected components. Decreases by unite.
};

int main(int argc, char** argv) {
  int N, M;
  cin >> N >> M;

  UnionFind tree(N);
  rep(i, M) {
    int X, Y, Z;
    cin >> X >> Y >> Z;
    --X; --Y; // 0-indexied.
    tree.unite(X, Y);
  }

  cout << tree.size() << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	vector<int> sum1(n), sum2(n);
	rep(i, n) cin >> a[i];
	rep(i, n) cin >> b[i];
	rep(i, n) cin >> c[i];
	sort(all(a));
	sort(all(b));
	sort(all(c));
	
	ll ans = 0;
	// bの各要素より大きいcの個数の累積和をsum1に格納
	rep(i, n){
		sum1[i] = c.end() - upper_bound(all(c), b[i]);
	}
	// bの各要素未満のaの個数の累積和をsum2に格納
	rep(i, n){
		sum2[i] = lower_bound(all(a), b[i]) - a.begin();
	}
	rep(i, n){
		ans += (ll) sum1[i] * sum2[i];
	}
	cout << ans << endl;
	// rep(i, n) printf("%d %d %d %d %d\n", a[i], b[i], c[i], sum1[i], sum2[i]);
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int N;
  cin >> N;
  
  vector<int>X(N);
  for(int i=0;i<N;i++){
    cin >> X[i];
  }
  
  int min = 999;
  int max = 0;
  for(int i=0;i<N;i++){
    if(X[i] > max) max = X[i];
    if(X[i] < min) min = X[i];
  }
  
  long long ans = 999999999;
  for(int i=min;i<=max;i++){
    long long sum = 0;
    for(int j=0;j<N;j++){
      sum += (X[j] - i) * (X[j] - i);
    }
    if(sum < ans) ans = sum;
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, M;
    cin >> N >> M;
    vector<bool> likes(M);
    REP(i, M) likes[i] = true;
    REP(i, N) {
        int k;
        cin >> k;

        vector<bool> tmp(M);
        REP(i, k) {
            int a;
            cin >> a;
            a--;
            tmp[a] = true;
        }
        REP(i, M) {
            if (!tmp[i]) {
                likes[i] = false;
            }
        }
    }

    int ans = 0;
    REP(i, M) if(likes[i]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*input
1000000000000
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll n;

bool check(ll t){
	ll m=n/t-1;
	if(m==0) return 0;

	return n%m==n/m;
}

int main(){
	IOS;
	cin>>n;
	ll ans=0;
	for(ll i=1;i*i<=n;i++){
		ans+=check(i)*(n/i-1);
		if(i*i!=n) ans+=check(n/i)*(i-1);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define endl "\n" 
#define p pair<int, int>
#define arrinp(i, a, start, end); for(ll i = start; i <= end; i++) cin >> a[i];
#define arrout(i, a, start, end); for(ll i = start; i <= end; i++) cout << a[i] << " ";
#define swap(a, b) {a = a + b; b = a - b; a = a - b;
#define forfront(i, start, end) for(ll i = start; i <= end; i++)
#define forback(i, start, end) for(ll i = start; i >= end; i--)
#define out(x) cout << x << " "
#define outline(x) cout << x << endl;
int main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int ele;
    int l;
    for(int i = 1; i < 6; i++)
    {
        cin >> l;
        if(l != i)
        {
            ele = i;
        }
    }
    outline(ele);
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

int main(void){
	int N;	cin >> N;
	string s;	cin >> s;
	int ans = 0;
	reps(i,N-1)	{
		string s1 = s.substr(0,i);
		string s2 = s.substr(i);
		int tmp = 0;
		for (char c='a'; c<='z'; c++)	{
			bool left=false, right=false;
			rep(i,s1.size())	{
				if (s1[i]==c)	left=true;
			}
			rep(j,s2.size())	{
				if (s2[j]==c)	right=true;
			}
			if (left&&right)	tmp++;
		}
		if (ans < tmp)	ans=tmp;
	}
	cout << ans << endl;
	return 0;
}


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

typedef long long ll;

int main()
{
    ll i,j;
    ll x,y;
    cin >> x >> y;
    if((x+y)%3){
        cout << 0 << endl;
        return 0;
    }
    
    ll max_number = (x+y)/3;
    int MOD = 1e9+7;
    ll l = x - max_number;
    ll k = y - max_number;
    if(l < 0 || k < 0){
        cout << 0 << endl;
        return 0;
    }
    vector<ll> fac(max_number+1,1);
    vector<ll> inv(max_number+1,1);
    vector<ll> finv(max_number+1,1);
    vector<ll> nCk(max_number+1,1);
    for(i = 2;i <= max_number;++i){
        inv.at(i) = MOD - inv.at(MOD%i)*(MOD/i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        fac.at(i) = fac.at(i-1)*i%MOD;
        finv.at(i) = finv.at(i-1)*inv.at(i)%MOD;
    }
    for(i = 1;i <= max_number;++i){
        nCk.at(i) = fac.at(max_number)*finv.at(i)%MOD*finv.at(max_number-i)%MOD;
    }

    cout << nCk.at(l) << endl;

    return 0;
}

Measured memory_bytes: 21120
# coding: utf-8
h, w = list(map(int, input().split()))
ls = [list(input()) for y in range(h)]
ls.append(list("." * w))
ls = [list("." * w)] + ls

for i in range(h + 2):
    ls[i].append(".")
    ls[i] = ["."] + ls[i]
ans = [[0 for x in range(w+2)] for y in range(h+2)]

for y in range(1, h+1):
    for x in range(1, w+1):
        if ls[y][x] == "#":
            ans[y][x] = "#"
        else:
            ans[y][x] = [ls[y-1][x-1], ls[y-1][x], ls[y-1][x+1], ls[y][x-1], ls[y][x+1], ls[y+1][x-1], ls[y+1][x], ls[y+1][x+1]].count("#")

for i in range(1, h+1):
    print(''.join(map(str, ans[i]))[1:w+1])

Measured memory_bytes: 3064
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<string> S;
  int mid = S.length() / 2;
  for (int i = 0; i <= mid; i++)
    if (S[mid - i] != S[mid + i])
      return "No";
  int qmid = S.length() / 2;
  for (int i = 0; i < mid/2; i++)
    if (S[i] != S[mid-1 - i])
      return "No";



  return "Yes";
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll> > vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
const long long INF = numeric_limits<ll>::max();
const long long MOD = 1000000007;
const long double PI = 3.1415926;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
//char c;
 
#define Endl endl
 
/*--------------------template--------------------*/
int main() {
    ll N;
    cin>>N;
    ll M=0,A=0,R=0,C=0,H=0;
    REP(i,N){
        string s;
        cin>>s;
        switch(s[0]){
            case 'M':
                M++;
                break;
            case 'A':
                A++;
                break;
            case 'R':
                R++;
                break;
            case 'C':
                C++;
                break;
            case 'H':
                H++;
                break;
        }
    }
    vi v=vi{M,A,R,C,H};
    REP(i,5)FOR(j,i+1,5)FOR(k,j+1,5)ans+=v[i]*v[j]*v[k];
    cout<<ans<<endl;
    
    return 0;
}

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

// void call(int n)
// {
//     int i = 1;
// CHECK_NUM:
//     int x = i;
//     if(x % 3 == 0) {
//         cout << " " << i;
//         goto END_CHECK_NUM;
//     }
// INCLUDE3:
//     if(x % 10 == 3) {
//         cout << " " << i;
//         goto END_CHECK_NUM;
//     }
//     x /= 10;
//     if(x) goto INCLUDE3;
// END_CHECK_NUM:
//     if(++i <= n) goto CHECK_NUM;

//     cout << endl;
// }

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

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

    call(n);

    return 0;
}

Measured memory_bytes: 1160
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
#include <functional>																							   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra																													   																				   list<int>::iterator it;																								   
																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    
    int n;
    int h[105];
    cin >> n;
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	
	int ans = 1;
	for(int i = 1; i < n; i++){
		bool check = true;
		for(int j = 0; j < i; j++){
			if(h[j] > h[i]){
				check = false;
			}
		}
		if(check) ans++;
	}
	
	cout << ans << endl;
	
	
	
	
	
	
	
    
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    int sum=z;
    int ans=0;
    while(sum+y+z<=x){
        ans++;
        sum=sum+y+z;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n,k;
	cin>>n>>k;
	int arr[n];
	for (int i = 0; i < n; i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int sum=0;
	for (int i = 0; i < k; i++){
		sum += arr[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

int p;
int a[3005];
void input(){
    cin>>p;
    rep(i,p)cin>>a[i];
}

int pol[3005];
int ans[3005];
void solve(){
    pol[p]=1;
    pol[1]=p-1;
    rep(j,p)if(a[j]==1){
        int tmp[3005];
        rep(k,p+1)tmp[k]=pol[k];
        for(int i=p; i>=1; i--){
            tmp[i-1]=(tmp[i-1]+tmp[i]*j)%p;
        }
        rep(i,p)ans[i]=(ans[i]+tmp[i+1])%p;
    }
    rep(i,p)cout<<(p-ans[i])%p<<" ";
}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

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

bool equal(int p1[],int p[],int n)
{
    for(int i=0;i<n;i++)
    {
        if(p1[i]!=p[i])
        {
            return false;
        }
    }
    
    return true;
}
int main()
{
    int n;
    cin>>n;
    
    int p[n],q[n],p1[n],q1[n],rank_p=0,rank_q=0;
    
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        
        p1[i]=x;
        p[i]=x;
    }
    
    for(int i=0;i<n;i++)
    {
        int x1;
        cin>>x1;
        
        q1[i]=x1;
        q[i]=x1;
    }
    
    sort(p1,p1+n);
    sort(q1,q1+n);
    
    do
    {
        if(equal(p1,p,n))
        {
            break;
        }
        
        rank_p++;
    }while(next_permutation(p1,p1+n));
    
    do
    {
        if(equal(q1,q,n))
        {
            break;
        }
        
        rank_q++;
    }while(next_permutation(q1,q1+n));
    
    
    cout<<abs(rank_p - rank_q)<<endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
// typedef
typedef long long ll;
typedef long double ldbl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
 
// container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
#define FOR(i,m,n) for (ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for (ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)
 
// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl
 
// constant
const double PI  = acos(-1.0);
const int    MOD = (int)(1e9 + 7);
// DO NOT set INFTY_XXXs constants. They may bring some BUG! Use MAX_XXXs in climit instead.
 
// clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl


template<typename T>
inline vector<T> cin_vector(const size_t n) {
     vector<T> vec;
    vec.reserve(n);
    REP(i, n) {
        T element; cin >> element;
        vec.push_back(element);
    }
    return vec;
}

template<typename T>
inline vector< vector<T> > cin_matrix(const size_t m, const size_t n) {
    vector< vector<T> > matrix;
    matrix.reserve(m);
    REP(i, m) {
        vector<T> vec = cin_vector<T>(n);
        matrix.push_back(vec);
    }
    return matrix;
}

template<typename T>
inline void cout_vector(const vector<T>& vec) {
    REP(i, SZ(vec)-1) {
       cout << vec[i] << ' ';
    }
    cout << vec[SZ(vec)-1] << endl;
}

template<typename T>
inline void cout_matrix(vector< vector<T> > matrix) {
    for(const vector<T>& vec : matrix) {
         cout_vector<T>(vec);
    }
}

ll cost(const vll& xv, ll p) {
    ll ret = 0;
    for(const ll x : xv) {
        ret += (x-p)*(x-p);
    }
    return ret;
}

int main() {
    ll n; cin >> n;
    vll xv = cin_vector<ll>(n);
    ll ans = -1;
    FOR(p, 1, 101) {
        ll candidate = cost(xv, p);
        if (ans == -1 || ans > candidate) {
            ans = candidate;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  static long[] depth;
  static ArrayList[] edge;

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    depth = new long[n];
    edge = new ArrayList[n];
    for(int i = 0; i < n; i++) {
      edge[i] = new ArrayList<Edge>();
    }
    for(int i = 0; i < n - 1; i++) {
      int a = sc.nextInt() - 1;
      int b = sc.nextInt() - 1;
      long c = sc.nextLong();
      Edge e1 = new Edge(b, c);
      Edge e2 = new Edge(a, c);
      edge[a].add(e1);
      edge[b].add(e2); 
    }
    int Q = sc.nextInt();
    int K = sc.nextInt() - 1;
    dfs(K, -1, 0);
    for(int i = 0; i < Q; i++) {
      int x = sc.nextInt() - 1;
      int y = sc.nextInt() - 1;
      System.out.println(depth[x] + depth[y]);
    }
  }

  public static void dfs(int v, int parent, long d) {
    depth[v] = d;
    ArrayList<Edge> elist = edge[v];
    for(int i = 0; i < elist.size(); i++) {
      Edge e = elist.get(i);
      if(e.to != parent) dfs(e.to, v, e.cost + depth[v]); 
    } 
  }
}

class Edge {
  int to;
  long cost;
  Edge(int to, long cost) {
    this.to = to;
    this.cost = cost;
  }
}

Measured memory_bytes: 189404
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

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

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  ll ans = 1;
  int num[30] = {};
  int n; cin>>n;
  string s; cin >> s;
  for (char c : s) num[c-'a']++;
  rep(i, 26) {
    ans*=num[i]+1;
    ans%=MOD;
  }
  outl((ans+MOD-1)%MOD);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 512
N = input()
_line = input()
line = _line.split()
S = 0.0
for i in range(int(N)):
  S += float(line[i])
tag=0
for i in range(int(N)):
  if S > float(line[i])*2:
    continue
  else:
    print("No")
    tag=1
    break
if tag==0:
  print("Yes")



Measured memory_bytes: 3060
#include <cstdio>

const int maxn=200000;

int read()
{
  int x=0,f=1;
  char ch=getchar();
  while((ch<'0')||(ch>'9'))
    {
      if(ch=='-')
        {
          f=-f;
        }
      ch=getchar();
    }
  while((ch>='0')&&(ch<='9'))
    {
      x=x*10+ch-'0';
      ch=getchar();
    }
  return x*f;
}

int n,a[maxn+10];
long long ans;

int main()
{
  n=read();
  for(int i=1; i<=n; ++i)
    {
      a[i]=read();
      if(a[i]>=i)
        {
          puts("-1");
          return 0;
        }
    }
  for(int i=2; i<=n; ++i)
    {
      if(a[i]>a[i-1]+1)
        {
          puts("-1");
          return 0;
        }
      if(a[i]==a[i-1]+1)
        {
          ++ans;
        }
      else
        {
          ans+=a[i];
        }
    }
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
bool check(int x, int sum, vector<int>&a, int n, int k){
    vector<int>v;
    f(i, n)v.push_back(a[i] % x);
    if(accumulate(v.begin(), v.end(), 0) == 0)return true;
    sort(v.begin(), v.end());
    int diff = 0, pls = 0;
    f(i, n){
        diff += v[i];
        pls = 0;
        for(int j = i + 1; j < n; ++j){
            pls += x - v[j];
        }
        if(pls == diff && diff <= k)return true;

    }

    return false;
}

void input(){
    int n, k; cin >> n >>k;
    vector<int>a(n);
    int sum = 0;
    f(i, n){
        cin >> a[i]; sum += a[i];
    }
    if(n == 1){
        cout << a[0] << endl;return;
    }
    int ans = 1;
    for(int i = 1; i * i <= sum; ++i){
        if(sum % i == 0){
            if(check(i, sum, a, n, k))ans = max(ans, i);
            if(check(sum / i, sum, a, n, k))ans = max(ans, sum / i);
        }
    }
    cout << ans << endl;
}
int main()
{
 input();
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include<algorithm> 
#include <iomanip>
#include <math.h>
#include <iostream>
#include <bitset>
#include <map>

#define db double
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define maxn 5005
#define mod 998244353
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define vv(z,a,b) vector<vector<int>>z(a,vector<int>(b))
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(c) begin(c),end(c)
#define pp pair<int,int>
#define fix(n) fixed << setprecision(n)
#define gmax(a,b) __gcd(a,b)
#define gmin(a,b) a/__gcd(a,b)*b
using namespace std;
//obj;
class binary{
public:
    bool isOK(int index, int key,vi a) {
    if (a[index] >= key) return true;
    else return false;
}
int binary_search(int key,vi a) {
   
    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int ok = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* ok と ng のどちらが大きいかわからないことを考慮 */
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key,a)) ok = mid;
        else ng = mid;
    }
    return ok;
}
}obj;

int main(){
int n;
cin>>n;
vll a(n);
rep(i,n)cin>>a.at(i);
sort(all(a));
int i=n-1;
ll ans=0;
while(i>=2){
    rep(j,i){
        for(int k=j+1;k<i;k++){
            ll b=a.at(j)+a.at(k);
            ll c=a.at(j)+a.at(i);
            ll d=a.at(k)+a.at(i);
            if((a.at(i)<b)&&(a.at(k)<c)&&(a.at(j)<d))
            {
                if((a.at(j)<a.at(k))&&(a.at(k)<a.at(i))){
                        ans++;
                }
            }
        }
    }
    i--;

}
cout<<ans<<endl;


return 0;
 }


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int a,b; cin >> a >> b;
    if(a<=8 && b<=8)cout << "Yay!" << endl;
    else cout << ":(" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

int main(int argc, char** argv) {
  unsigned N, K;
  std::cin >> N >> K;
  std::vector<int> H(N);
  for (auto& e : H) std::cin >> e;
  unsigned cnt {};
  for (auto& e : H) {
    if (e >= K) {
      ++cnt;
    }
  }
  std::cout << cnt << '\n';
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

void solve() {
	int n;
	cin >> n;
	cout << n*(n+1)/2;
 		
}
		
			
		

int32_t main() {
	IOS;
	solve();
	return 0;
}


Measured memory_bytes: 256
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn bfs(start: usize, n: usize, v: &Vec<Vec<usize>>) -> Vec<usize> {
    let mut dist = vec![usize::max_value(); n];
    dist[start] = 0;
    let mut q = VecDeque::new();
    q.push_back(start);
    while !q.is_empty() {
        let pos = *q.front().unwrap();
        q.pop_front().unwrap();
        for next in v[pos].iter() {
            if dist[*next] <= dist[pos] {
                continue;
            }
            dist[*next] = dist[pos] + 1;
            q.push_back(*next);
        }
    }
    dist
}

fn main() {
    let n = get!(usize);
    let mut v = vec![Vec::new(); n];
    for _ in 0..n - 1 {
        let (a, b) = get!(usize, usize);
        let a = a - 1;
        let b = b - 1;
        v[a].push(b);
        v[b].push(a);
    }
    let black_dist = bfs(0, n, &v);
    let white_dist = bfs(n - 1, n, &v);
    //eprintln!("B {:?}", black_dist);
    //eprintln!("W {:?}", white_dist);
    let mut black = 0;
    let mut white = 0;
    for i in 0..n {
        if black_dist[i] <= white_dist[i] {
            black += 1;
        } else {
            white += 1;
        }
    }
    //eprintln!("B {}, W{}", black, white);
    if white < black {
        println!("Fennec");
    } else if black <= white {
        println!("Snuke");
    }
}


Measured memory_bytes: 12540
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    double n=sc.nextInt();
    if (n%2==0) {
      double b=(n/2)/n;
      System.out.println(b);
    }else{
      double b=((n+1)/2)/n;
      System.out.println(b);
    }
  }
}


Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int n;
    cin >> n;
    unordered_set<char> us;
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        us.insert(c);
    }
    if (us.size() == 3) {
        cout << "Three" << endl;
    } else {
        cout << "Four" << endl;
    }
}


Measured memory_bytes: 3600
package main
import "fmt"
// import "sort"

func main()  {
    var S string

    fmt.Scan(&S)

    var ans int
    ans = 0
    for digit := 0; digit < 3; digit++ {
        ans *= 10
        if S[digit] == '9' {
            ans += 1
        } else {
            ans += 9
        }
    }

    fmt.Println(ans)
}

Measured memory_bytes: 512