akhauriyash/Code-Regression huggingface dataset:
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int N = nextInt();
        Point[] points = new Point[N];
        Arrays.setAll(points, i->new Point(nextInt(), nextInt()));

        int[] index = new int[N];
        for(int i=0; i<N; i++){
            index[i] = i;
        }

        double sum = 0;
        int count = 0;
        do{
            for(int i=0; i<N-1; i++){
                sum += points[index[i]].distance(points[index[i+1]]);
            }
            count++;
        }while(nextPermutation(index));
        println(sum/count);
    }

    public static boolean nextPermutation(int[] a) {
        for (int i = a.length - 1; i > 0; --i) {
            if (a[i - 1] < a[i]) {
                int swapIndex = find(a[i - 1], a, i, a.length - 1);
                int temp = a[swapIndex];
                a[swapIndex] = a[i - 1];
                a[i - 1] = temp;
                Arrays.sort(a, i, a.length);
                return true;
            }
        }
        return false;
    }
    private static int find(int dest, int[] a, int s, int e) {
        if (s == e) {
            return s;
        }
        int m = (s + e + 1) / 2;
        return a[m] <= dest ? find(dest, a, s, m - 1) : find(dest, a, m, e);
    }


    static Point[] nextArray(Point[] points){
        Point[] array = new Point[points.length-1];
        for(int i=0; i<array.length; i++){
            array[i] = points[i=1];
        }
        return array;
    }

    static int nextInt() {
        return Integer.parseInt(next());
    }

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 26836
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  while(1){
    ll n;
    cin>>n;
    if(n==0) break;
    vector<ll> v(n);
    rep(i,n) cin>>v[i];
    sort(ALL(v));
    vector<ll> ans(n-1);
    rep(i,n-1){
      ans[i]=abs(v[i]-v[i+1]);
    }
    sort(ALL(ans));
    cout<<ans[0]<<endl;
  }
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    double ans = 0;
    for(int i = 0; i < N; i++) {
        double x; string u;
        cin >> x >> u;
        ans += (u=="BTC" ? x*380000.0 : x);
    }
    cout << fixed << setprecision(5) << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO cin.tie(NULL); ios_base::sync_with_stdio(false);
#define ll long long int
#define ii pair<int,int>
#define endl '\n'
using namespace std;
void solve()
{
    char c;
    cin >> c;
    if('A'<= c && c<= 'Z')
        cout << 'A' << endl;
    else
        cout << 'a' << endl;
}
int main()
{
   FASTIO
/* 	int t;
	cin >> t;
	while (t--) */
        solve();
}

Measured memory_bytes: 3644
s = input()
mod = 10**9 + 7
N = len(s)
if s[-1]=="?":
    dp = [1]*13
    dp[10:13] = [0,0,0]
else:
    dp = [0]*13
    dp[int(s[-1])] = 1
if N==1:
    print(dp[5])
    exit()
else:
    mul = 10
    for i in reversed(range(N-1)):
        nextdp = [0] * 13
        if s[i]=="?":
            for j in range(10):
                for k in range(13):
                    l = (j*mul+k) % 13
                    nextdp[l] += dp[k]
                    nextdp[l] %= mod
        else:
            for k in range(13):
                l = (int(s[i])*mul+k) % 13
                nextdp[l] += dp[k]
                nextdp[l] %= mod
        mul *= 10
        mul %= 13
        dp = nextdp
    print(dp[5])
    exit()

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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n,k;
    cin >> n >> k;
    int a[k];
    int max1 = 0;
    REP(i,k){
        cin >> a[i];
        max1 = max(a[i],max1);
    }
    if (n-2*max1>0)COUT(0);
    else COUT(2*max1-n-1);
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int main(){
    int n; string s;
    cin >> n >> s;
    int maxV=0;
    for(int i=0; i<s.size(); ++i){
        int ans=0;
        int a[26]={0}, b[26]={0};
        for(int j=0; j<=i; ++j){
            a[s[j]-'a']++;
        }
        for(int j=i+1; j<s.size(); ++j){
            b[s[j]-'a']++;
        }
        for(int j=0; j<26; ++j){
            if(a[j]>=1&&b[j]>=1)ans++;
        }
        maxV = max(ans, maxV);
    }
    cout << maxV << endl;
    return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define eb emplace_back

using ll = int64_t;

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int64_t a;cin >> a;
    cout << a + a * a + a * a * a << '\n';
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  V a(n), b(n), c(n);
  REP(i, n) {
    cin >> a[i];
  }
  REP(i, n) {
    cin >> b[i];
  }
  REP(i, n) {
    cin >> c[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll x, y;
  ll ret = 0;
  REP(i, n) {
    x = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
    y = n - (upper_bound(c.begin(), c.end(), b[i]) - c.begin());
    ret += x*y;
  }
  dump(ret);
  return 0;
}


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

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

int main() {
	string S;
	cin >> S;

	if(S.size()==1){
		cout << 1 << endl;
		return 0;
	}

	int i;

	int ans1=1;
	char now=S.at(0);
	bool flag=false;
	for(i=1;i<S.size();i++){
		if(flag){
			flag=false;
			now=S.at(i);
			ans1++;
		}
		else{
			if(now==S.at(i)){
				flag=true;
				ans1++;
				i++;
			}
			else{
				flag=false;
				now=S.at(i);
				ans1++;
			}
		}
	}
	if(flag==true && S.at(S.size()-2)==S.at(S.size()-1)){
		if(i==S.size()+1)	ans1--;
	}
	//cout << ans1 << endl;
	
	int ans2=1;
	flag=true;
	for(i=2;i<S.size();i++){
		if(flag){
			flag=false;
			now=S.at(i);
			ans2++;
		}
		else{
			if(now==S.at(i)){
				flag=true;
				ans2++;
				i++;
			}
			else{
				flag=false;
				now=S.at(i);
				ans2++;
			}
		}
	}
	if(flag==true && S.at(S.size()-2)==S.at(S.size()-1)){
		if(i==S.size()+1)	ans2--;
	}
	//cout << ans2 << endl;
	cout << max(ans1,ans2) << endl;

	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<math.h>
using namespace std;
 
int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
for(int i=0;i<=k;i++){
    int bn=b*pow(2,i);
    int cn=c*pow(2,k-i);
    if (a<bn and bn<cn){
        cout<<"Yes";
        return 0;
    }
    }
cout<<"No";
}


Measured memory_bytes: 4120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

unsigned int randxor() {
  static unsigned int x=123456789,y=362436069,z=521288629,w=88675123;
  unsigned int t;
  t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}




int main() {
  int D;
  cin >> D;
  vector<int> c(26);
  rep(i,26) cin >> c[i];
  vector<vector<int>> s(D, vector<int>(26));
  vector<int> last_day(26, 0);
  vector<int> t(D);
  rep(i,D) rep(j,26) cin >> s[i][j];

  int score = 0;
  int res = 0;
  auto Scoring = [&](int d, int id, int oid) {
    if (oid != -1) score -= s[d - 1][oid];
    score += s[d - 1][id];
    last_day[id] = d;
    for (int i = 0; i < 26; i++) score -= c[i] * (d - last_day[i]); 
    res = max((int)1e6 + score, 0);
  };

  auto init = [&](){
    while (res < 1000) {
      score = 0;
      res = 0;
      for (int i = 0; i < D; i++) {
        int q = randxor() % 26;
        t[i] = q;
        Scoring(i + 1, q, -1);
      }
    }
  };
  
  //計算  
  init();
  rep(p, 40000000) {

    int d = randxor() % D;
    int change_q = randxor() % 26;    
    int old_q = t[d];
    t[d] = change_q;
    int old_res = res;
    int old_score = score;
    Scoring(d + 1, change_q, old_q);
    if (res < old_res) {
      t[d] = old_q;
      res = old_res;
      score = old_score;
    }
  }

  //cout << res << endl;
  rep(i,D) cout << t[i] + 1 << endl;
  return 0;
} 

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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll S;
    cin >> S;
    // 1000000000000000000
    ll x = (1000000000-S%1000000000) % 1000000000;
    ll y = (S+x) / 1000000000;
    cout << "0" << " "  << "0" << " " << "1000000000" << " " << "1" << " " << x << " " << y << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int MAX=2100000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for (int i=2;i<MAX;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i - 1]*inv[i]%MOD;
	}
}
long long COM(int n, int k){
	if(n<k) return 0;
	if(n<0||k<0) return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

ll power(ll x, ll y) {
	if (y==0) return 1;
	else if (y==1) return x%MOD;
	else if (y%2==0) { ll pow=power(x,y/2); return (pow*pow)%MOD; } 
	else { ll pow=power(x,y/2); return ((pow*pow)%MOD)*x%MOD; }
}

int main(){
	COMinit();
	ll k; cin >> k;
	string s; cin >> s;
	ll n=s.size();
	ll ans=0;
	for(int i=n;i<=n+k;i++){
		ll sum=COM(i-1,n-1);
		sum*=(power(25,i-n)*power(26,n+k-i))%MOD;
		ans+=sum;
		ans%=MOD;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> as(n);
    for(int i=0; i<n; i++) cin >> as.at(i);
    for(auto a : as)
    {
        if(a == 0)
        {
            cout << 0 << '\n';
            return 0;
        }
    }
    ll ans = 1;
    for(auto a : as)
    {
        if(log10l(a) + log10l(ans) > 18)
        {
            cout << -1 << '\n';
            return 0;
        }
        else if(log10l(a) + log10l(ans) > log10l(1LL << 60))
        {
            cout << -1 << '\n';
            return 0;
        }
        else if(a * ans > static_cast<ll>(1e18))
        {
            cout << -1 << '\n';
            return 0;
        }
        ans *= a;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3996
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

typedef long long ll;

struct city {
	ll num;
//	int ans1;
	int ans2;
	int y;
	int p;
};

//struct data_t {
//    int num;
//    string str;
//} ;

// 比較関数を定義
bool asc_y( const city& left, const city& right ) {
//    return left.num == right.num ? left.str < right.str : left.num < right.num;
    return left.y < right.y;
}
//ソートの第三引数に比較関数を追加する。
//sort(data_array.begin(), data_array.end(), asc);


// 比較関数を定義
bool asc_n( const city& left, const city& right ) {
//    return left.num == right.num ? left.str < right.str : left.num < right.num;
    return left.num < right.num;
}

int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> P(M), Y(M), ans(M), T(N, 1);
	vector<city> C(M);

	for (int i = 0; i < M; i++) {
		C[i].num = i;
		cin >> C[i].p >> C[i].y;
	}

	sort(C.begin(), C.end(), asc_y);

	//古いやつから消していく
	for (int i = 0; i < M; i++) {
		C[i].ans2 = T[C[i].p-1];
		T[C[i].p-1]++;
	}

	sort(C.begin(), C.end(), asc_n);

	for (int i = 0; i < M; i++) {
		printf("%06d%06d\n", C[i].p, C[i].ans2);
	}
}

Measured memory_bytes: 7040
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    int n, a[100005] = {};
    ll d[100005][2] = {};
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    d[1][0] = a[1];
    d[1][1] = -1ll * mod * mod;
    for (int i = 2; i <= n; i++) {
        d[i][0] = max(d[i - 1][0], d[i - 1][1]) + a[i];
        d[i][1] = max(d[i - 1][0] - a[i - 1] - a[i - 1], d[i - 1][1] + a[i - 1] + a[i - 1]) - a[i];
    }
    cout << max(d[n][0], d[n][1]);
}


Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int ans = h2*60+m2-(h1*60+m1)-k;
    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <set>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cmath>
#include <deque>
#include <bitset>
#define ll long long
#define PI 3.1415926535897932384626433832795
#define read(x) scanf("%d",&x);
#define readll(x) cin>>x;
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define MP make_pair
#define PB push_back
#define pii pair<int,int>
#define readN(N,X) for(int i=0;i<N;i++) cin>>X[i];
#define pff pair<double,double>
using namespace std;

int N;
int a[200005];
int ans[500005];
int F = 200000;
int L = 200001;

int main(){
   std::ios::sync_with_stdio(false); 
   cin>>N;
   readN(N,a);
   memset(ans,-1,sizeof(ans));
   bool rev = 0;
   FOR(i,0,N){
   		if (rev) {
   			ans[L++] = a[i];
   		} else {
   			ans[F--] = a[i];
   		}
   		rev = 1 - rev;
   }
   vector<int> res;
   for (int i=F;i<=L;i++)
   	res.push_back(ans[i]);
   if (!rev) reverse(res.begin(), res.end());
   for (int x: res)
   		if (x !=-1)cout<<x<<" ";

}



Measured memory_bytes: 5876
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename Out>
void split(const std::string &s, char delim, Out result) {
    std::stringstream ss(s);
    std::string item;
    while (std::getline(ss, item, delim)) {
        *(result++) = item;
    }
}

std::vector<std::string> split(const std::string &s, char delim) {
    std::vector<std::string> elems;
    split(s, delim, std::back_inserter(elems));
    return elems;
}

int main() {
  string s; cin >> s;
  vector<string> sp = split(s, '/');
  vector<string> cm = {"2019", "04", "30"};
  
  for(int i=0; i<3; i++){
    int s = stoi(sp[i]), t = stoi(cm[i]);
    if(s > t){
      cout << "TBD" << endl;
      return 0;
    }
  }

  cout << "Heisei" << endl;

  return 0;
}


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

using namespace std;
#define mx 200000
int main(){


   string s;
   int a;


   cin>>a>>s;

   for(int i=0;i<s.size();i++){

     int x = s[i]-'A';

      x= (x+a)%26;
      s[i] = (char)(x+'A');
   }
cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	cin>>n;

	vi l(n);

	rep(i, n) cin>>l[i];

	sort(all(l));

	int sum=0;
	rep(i, n-1) sum+=l[i];

	cout<<yn(l[n-1]<sum)<<endl;
}


Measured memory_bytes: 256
inpl = lambda: list(map(int, input().split()))
H, W = inpl()
def next_sq(sq):
  h, w = sq
  if h % 2 == 0:
    if w == W-1:
      return h+1, w
    else:
      return h, w+1
  else:
    if w == 0:
      return h+1, w
    else:
      return h, w-1

a = [inpl() for _ in range(H)]
n = sum(sum(a[h][w] % 2 for w in range(W)) for h in range(H))
if n < 2:
  print(0)
  exit()
sq = (0, 0)
prev = None
ans = []
for _ in range(H*W):
  h, w = sq
  if prev is not None:
    ans.append((prev[0]+1, prev[1]+1, h+1, w+1))
    if a[h][w] % 2:
      n -= 1
      if n < 2:
        break
      prev = None
    else:
      prev = sq
  elif a[h][w] % 2:
    n -= 1
    prev = sq
  sq = next_sq(sq)

print(len(ans))
for line in ans:
    print(line[0], line[1], line[2], line[3])

Measured memory_bytes: 26652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N;
  cin >> N;
  ll H[N];
  ll ans = 0;
  ll count = 0;

  if (N == 1) {
    cout << 0 << endl;
  }
  else {
  for (int i = 0; i < N; i++) {
    cin >> H[i];
  }
  bool O[N - 1] = {false};
  for (int i = 1; i < N; i++) {
    if (H[i - 1] >= H[i]) {
      O[i - 1] = true;
    }
    else {
      O[i - 1] = false;
    }
  }
  for (int i = 0; i < N - 1; i++) {
    if (O[i] == true) {
      count++;
    }
    else {
      ans = max(ans,count);
      count = 0;
    }
  }
  ans = max(ans,count);
  cout << ans << endl;
}
  return 0;
}

Measured memory_bytes: 1152
import sys
dic = {}
for s in sys.stdin:
    arr = s.split()
    if arr[0] in dic:
        a = dic[arr[0]]
        dic[arr[0]] = a + [int(arr[1])]
    else:
        dic[arr[0]] = [int(arr[1])]
for i in sorted(dic):
    print(i)
    a = sorted(dic[i])
    for j in range(len(a)):
        if j != len(a)-1:
            print(a[j], end=" ")
        else:
            print(a[j])

Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

void printVector(vector<int> v) {
    for (auto x : v) {
        cout << x << ' ';
    }
    cout << '\n';
}

void printArray(ll A[], int size) {
    for (int i = 0; i <= size - 1; i++) cout << A[i] << ' ';
}

int main() {
    int a, b;
    cin >> a >> b;
    int ans = max(max(2 * a - 1, 2 * b - 1), a + b);
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h> 
using namespace std; 
typedef long long ll;
const ll mxN = 1e5;
const ll mod = 1e9 + 7;
 
ll pow(ll a,ll b){
    ll r =1;
    while(b){
        if(b%2!=0) r=(r*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return r;
}
 
const int sz = 5e5+20;
ll fact[sz], inv[sz];
void pre(){
	fact[0] = 1;
	inv[0] = pow(fact[0], mod-2);
	for(int i=1;i<sz;i++){
		fact[i] = (fact[i-1]*i)%mod;
	}
}
 
int spf[10];
void sieve(){
    spf[1]=1;
    for(int i=2;i<mxN;i++) spf[i]=i;
    for(int i=4;i<mxN;i+=2) spf[i]=2;
    for(int i=3;i*i<mxN;i++){
    }
}

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

    ll n;
    cin>>n;

    if(n<3) {
        cout<<0<<endl;
        return 0;
    }
    ll dp[n+1];

    memset(dp,0,sizeof(dp));

    dp[0]=1;

    for(int i=3;i<=n;i++){
        for(int j=3;j<=min(n,(ll)i);j++){
            dp[i] = (dp[i-j]+dp[i])%mod;
        }
    }

    cout<<dp[n]<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main() {

   int n;
   cin>>n;
  // int ans=0;
   multiset <int> st;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       if(i==0)
       {st.insert(x);
           continue ;}
       auto it=st.lower_bound(x);

     //  it--;
       if(it==st.begin())
       {
           st.insert(x);
       }
       else
           {
           it--;
           st.erase(it);
           st.insert(x);
           }

   }


   cout<<st.size();
}


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

#define OnlineJudge1

#define loop(x,a,n) for(int x = a;x < n;x++)
#define NumofDigits(n) ((int)log10(n)+1)
#define CountofNumber(array,n,x)  (upper_bound(array, array+n, x)-lower_bound(array, array+n, x))
#define readline(s) getline(cin,s)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define EPS 1e-7
#define modulo ll (1e9 + 7)
const long double PI = 3.141592653589793238L;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
typedef pair<ll,ll> pll;

#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)

#define time__(d) \
    for ( \
        auto blockTime = make_pair(chrono::high_resolution_clock::now(), true); \
        blockTime.second; \
        debug("%s: %lld ms\n", d, chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - blockTime.first).count()), blockTime.second = false \
    )

void init(){
    cin.tie(0);
    ios::sync_with_stdio(0);
#ifdef OnlineJudge
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
#endif
}


int main(){
    init();

    set<int> s;
    for(int i = 0;i < 3;i++){
        int x;  cin >> x;
        s.insert(x);
    }
    cout << s.size();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a[1005],ans1=0,ans2=0;
    int c[15]={};
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(1<=a[i] && a[i]<=399 && c[1]!=1){
            c[1]=1;
            ans1++;
            ans2++;
        }
        if(400<=a[i] && a[i]<=799 && c[2]!=1){
            c[2]=1;
            ans1++;
            ans2++;
        }
        if(800<=a[i] && a[i]<=1199 && c[3]!=1){
            c[3]=1;
            ans1++;
            ans2++;
        }
        if(1200<=a[i] && a[i]<=1599 && c[4]!=1){
            c[4]=1;
            ans1++;
            ans2++;
        }
        if(1600<=a[i] && a[i]<=1999 && c[5]!=1){
            c[5]=1;
            ans1++;
            ans2++;
        }
        if(2000<=a[i] && a[i]<=2399 && c[6]!=1){
            c[6]=1;
            ans1++;
            ans2++;
        }
        if(2400<=a[i] && a[i]<=2799 && c[7]!=1){
            c[7]=1;
            ans1++;
            ans2++;
        }
        if(2800<=a[i] && a[i]<=3199 && c[8]!=1){
            c[8]=1;
            ans1++;
            ans2++;
        }
        if(3200<=a[i]){
            ans2++;
        }
        if(3200<=a[i] && ans1==0){
            ans1++;
        }
    }   
    cout<<ans1<<" "<<ans2<<endl;
    return(0);
}

Measured memory_bytes: 3616
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 1000000000
int main(){
	int n=0,tmp=0,tmp2=0,flag=0;
	int count=0;
	int a[1000000],z;
	

	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);	
	}
	for(int i=n-1;i>0;i--){
		tmp = i-1;
		if(a[i]==a[tmp]-1){
			a[tmp] -= 1;
		}else if(a[i] < a[tmp]-1){
			flag = 1;
		}
	}
	if(flag==1){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
}

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

typedef long long int lint ;

lint dp[100][21] = {0} ;
int n = 0 ;
int number[100] = {0} ;

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

    dp[0][ number[0] ] = 1 ;
    for ( int i = 0 ; i < n-2 ; i++ )
    {
        for ( int j = 0 ; j <= 20 ; j++ )
        {
            if ( j-number[i+1] >= 0 && j+number[i+1] <= 20 )
            {
                dp[ i+1 ][ j-number[i+1] ] += dp[i][j] ;
                dp[ i+1 ][ j+number[i+1] ] += dp[i][j] ;
            }
            else if ( j-number[i+1] < 0 )
            {
                dp[ i+1 ][ j+number[i+1] ] += dp[i][j] ;
            }
            else if ( j+number[i+1] > 20 )
            {
                dp[ i+1 ][ j-number[i+1] ] += dp[i][j] ;
            }
        }
    }
    printf("%lld\n",dp[ n-2 ][ number[ n-1 ] ]) ;

    return 0 ;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    int A,B;
  	cin>>A>>B;
  	if(A == B){
      cout<<"Yes"<<endl;
    }
  	else{
      cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    for (auto &v : a)
        cin >> v;
    
    ll count = 0;
    int len = 0;
    ll val = 0;
    forin(i, 0, n) {
        forin(j, i - len, i + 1) {
            if ((val & a[i]) == 0) {
                len = i - j + 1;
                break;
            } else {
                val &= ~a[j];
            }
        }
        val |= a[i];
        count += len;
        cerr << len << ' ';
    }
    cout << count << endl;
    
}



Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
using namespace std;
const int maxn=200000+10;
int n,A,B,C,D,flg;
char s[maxn];
int main(){
    scanf("%d%d%d%d%d",&n,&A,&B,&C,&D);
    scanf("%s",s+1);
    for(int i=A;i<C;++i)if(s[i]=='#'&&s[i+1]=='#')puts("No"),exit(0);
    for(int i=B;i<D;++i)if(s[i]=='#'&&s[i+1]=='#')puts("No"),exit(0);
    //A<B,A<C,B<D
    if(C>D){
        for(int i=B;i<=D;++i)
            if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')puts("Yes"),exit(0);
        flg=1;
    }
    puts(flg?"No":"Yes");
    return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N, X = MAP()
A = MAP()

B = [abs(X-a) for a in A]

def gcd(a, b):
	while b:
		a, b = b, a%b
	return a

ans = B[0]
for i in range(1, N):
	ans = gcd(ans, B[i])

print(ans)

Measured memory_bytes: 59800
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
s = sum(A)
m = Counter(A)
Q = int(input())
ls = []
for i in range(Q):
    b, c = map(int, input().split())
    s += m[b] * (c-b)
    m[c] += m[b]
    m[b] = 0
    print(s)

    # ls.append([int(j) for j in input().split()])


Measured memory_bytes: 24180
import java.util.*;


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

    int s=sc.nextInt();
		s+=10000;
		int k=s%100; //下２桁
		int t=s/100; //上２桁

		if((k>12 || k==0) && t<=112 && t!=100){
			System.out.println("MMYY");
		}else if(k<=12 && k!=0 && (t>112 || t==100)){
			System.out.println("YYMM");
		}else if(k<=12 && t<=112 && k!=0 && t!=100){
			System.out.println("AMBIGUOUS");
		}else{
			System.out.println("NA");
		}



	}
}


Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

int main(){
  string str; cin >> str;
  int score = 0;
  for(int i=0;i<str.size();i++){
    if(i %2==0){
      if(str[i] == 'g'){
        score += 0;
      }else{
        score -= 1;
      }
    }else{
      if(str[i] == 'g'){
        score += 1;
      }else{
        score += 0;
      }
    }
  }
  cout << score << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int n; cin >> n;
	ll sum = 0;
	for (int i = 1; i <= n; ++i){
		sum += i;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

evens = Counter(v[::2])
odds = Counter(v[1::2])

evens[0] = 0  # 一種類の数値しか含まれないときの対策
odds[0] = 0

keep = 0
for even in evens.most_common(2):
    for odd in odds.most_common(2):
        if even[0] != odd[0]:
            keep = max(keep, even[1] + odd[1])

print(n - keep)

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

int main() {
	string S;
	cin >> S;
	for (int i=0; i<S.size(); i++){
	    if (i%2==0){
	        if (S.at(i)!='R' && S.at(i)!='U' && S.at(i)!='D'){
	            cout << "No" << endl;
	            return 0;
	        }
	    }
	    if (i%2==1){
	        if (S.at(i)!='L' && S.at(i)!='U' && S.at(i)!='D'){
	            cout << "No" << endl;
	            return 0;
	        }
	    }
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int N;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N;
    vector<int> b(N,0);
    rep(i,0,N) cin>>b[i];
    vector<int> ans;
    rer(i,N+1,1){
        rer(j,i,0){
            if(b[j]==j+1){
                ans.pb(b[j]);
                b.erase(b.begin()+j);
                break;
            }
        }
        if(sz(b)!=i-1){
            cout <<-1<<"\n";
            return 0;
        }
    }
    rep(i,0,N){
        cout <<ans[N-1-i]<<"\n";
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc167/tasks/abc167_c

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DEBUG 1
#if DEBUG
  #define _GLIBCXX_DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

const int N_MAX = 12;
const int M_MAX = 12;
const int X_MAX = 1e5;
const int C_I_MAX = 1e5;
const int A_IJ_MAX = 1e5;
const int INF = 1e9;

int N, M, X;
vector<int> C;
vector<vector<int>> A;

int main() {
  cin >> N >> M >> X;
  C = vector<int>(N);
  A = vector<vector<int>>(N, vector<int>(M));
  REP(i, N) {
    cin >> C[i];
    REP(j, M) cin >> A[i][j];
  }

  int ans = INF;
  REP(s, 1 << N) {
    int cost = 0;
    vector<int> v = vector<int>(M, 0);
    REP(i, N) {
      if (s >> i & 1) {
        cost += C[i];
        REP(j, M) v[j] += A[i][j];
      }
    }
    bool ok = true;
    REP(j, M) if (v[j] < X) ok = false;
    if (ok) ans = min(ans, cost);
  }

  if (ans < INF) cout << ans << endl;
  else cout << -1 << endl;
}


Measured memory_bytes: 3652
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
int N,M; 
int T[110];
int P[110],X[110];
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d", &N);
    int sum = 0;
    for(int i=1;i<=N;i++) {scanf("%d", &T[i]);sum+=T[i];}
    scanf("%d", &M);
    for(int i=1;i<=M;i++) 
    {
        scanf("%d%d", &P[i], &X[i]);
        printf("%d\n", sum + (X[i] - T[P[i]]));
    }

    //system("pause");
}


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


int main()
{
	int h, n;
	cin >> h >> n;
	int a = 0;
	string ans = "No";
	for (int i = 0; i < n; i++) {
		int a_in;
		cin >> a_in;
		a += a_in;
		if (a >= h) {
			ans = "Yes";
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    string ans = "";
    REP(i,n){
        if(i==k-1){
            char c = 'a'+s[i]-'A';
            string sb = {c};
            ans+=sb;
        }else{
            char c = s[i];
            string sb = {c};
            ans+=sb;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 3e3 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

ll power(ll x, ll y) {
	ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
	int n, k; cin >> n >> k;
	int a[n];
	FOR(i, n) cin >> a[i];
	bool dp[k + 1] = {};
	// dp[i] -> if the value of K was i, then true if the first player would have won else...
	dp[0] = false;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j < n; j++) {
			if (i >= a[j] && dp[i - a[j]] == false) {
				dp[i] = true;
			}
		}
	}
	if (dp[k]) cout << "First";
	else cout << "Second";
	return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		double num ;
		while((num = sc.nextDouble()) != 0) {
			
			double divisor = 0;
		
			for(double i = 1;i * i <= num;i++) {
				if(num % i == 0) {
					if(Math.pow(i, 2) == num) {
						divisor += i;
					}else {
						divisor += i + num / i;
					}
				}
			}
			
			divisor -= num;
			
			if(divisor == num) {
				System.out.println("perfect number");
			}else if(divisor < num) {
				System.out.println("deficient number");
			}else {
				System.out.println("abundant number");
			}
		}
	}

}



Measured memory_bytes: 28452
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
	int n,a,b,c,d,ans;
	scanf("%d %d %d %d %d",&n, &a, &b, &c, &d);
	char s[n];
	scanf("%s", &s);
	a--;
	b--;
	c--;
	d--;
	ans=0;
	
	s[a]='a';
	s[b]='b';
//	printf("%s\n", s);
	if(c>d){	//a go first
		while(1){
		if(s[c]=='a'){
			if(s[d]=='b'){
				ans=1;
				break;
			}else{
				if(s[b+1]=='.'){
					s[b]='.';
					b++;
					s[b]='b';
				}else{
					if(s[b+2]=='.'){
						s[b]='.';
						b+=2;
						s[b]='b';
					}else{
						ans=0;
						break;
					}
				}
			}
		}else{
			if(s[a+1]=='.'){
				s[a]='.';
				a++;
				s[a]='a';
			}else{
				if(s[a+2]=='.'){
					s[a]='.';
					a+=2;
					s[a]='a';
				}else{
					if(s[d]=='b'){
						ans=0;
						break;
					}else{
						if(s[b+1]=='.'){
							s[b]='.';
							b++;
							s[b]='b';
						}else{
							if(s[b+2]=='.'){
								s[b]='.';
								b+=2;
								s[b]='b';
							}else{
								ans=0;
								break;
							}
						}
					}
				}
			}
		}
//		printf("%s\n", s);
		}
	}else{
		while(1){
		if(s[d]=='b'){
			if(s[c]=='a'){
				ans=1;
				break;
			}else{
				if(s[a+1]=='.'){
					s[a]='.';
					a++;
					s[a]='a';
				}else{
					if(s[a+2]=='.'){
						s[a]='.';
						a+=2;
						s[a]='a';
					}else{
						ans=0;
						break;
					}
				}
			}
		}else{
			if(s[b+1]=='.'){
				s[b]='.';
				b++;
				s[b]='b';
			}else{
				if(s[b+2]=='.'){
					s[b]='.';
					b+=2;
					s[b]='b';
				}else{
					if(s[c]=='a'){
						ans=0;
						break;
					}else{
						if(s[a+1]=='.'){
							s[a]='.';
							a++;
							s[a]='a';
						}else{
							if(s[a+2]=='.'){
								s[a]='.';
								a+=2;
								s[a]='a';
							}else{
								ans=0;
								break;
							}
						}
					}
				}
			}
		}
//		printf("%s\n", s);
		}
	}
	if(ans==1)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fr(i,k,n) for(int i=k;i<n;i++)
#define read(x) cin>>x
#define ll long long int
#define mod 1000000007 
#define print(x) cout<<x<<endl
#define pb(x) push_back(x)
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main() { 
    fastIO;
     int t=1,n;
     //cin>>t;
     while(t--){
      cin>>n;
       set<string>s;
       int ans=0;
      vector<string>arr;
       string input;
       fr(i,0,n){
       cin>>input;
         arr.push_back(input);
         if(!s.count(arr[i]))
            {ans ++;
             s.insert(arr[i]) ;}
            }
        
   cout<<ans;   
         
     }
	 
	return 0;
}


Measured memory_bytes: 25052
from fractions import gcd

def lcm(x, y):
    return x * y // gcd(x, y)

n, m = map(int, input().split())
a = [i // 2 for i in set(list(map(int, input().split())))]
b = []
for i in a:
    cnt = 0
    while i % 2 == 0:
        i //= 2
        cnt += 1
    b.append(cnt)

L = 1
ans = 0
if len(set(b)) == 1:
    for j in a:
        L = lcm(j, L)
        if m < L:
            ans = 0
            break
        else:
            ans = (m // L + 1) // 2
    print(ans)
else:
    print(0)


Measured memory_bytes: 16336
from collections import deque

N, K = map(int, input().split())
P = list(map(int, input().split()))

exps = [-1.0] * 1001
seed = 0
for i in range(1, 1001):
    seed += i
    exps[i] = seed / i

total = 0
heads = deque()
for k in range(K):
    p = P[k]
    exp = exps[p]
    total += exp
    heads.append(exp)
ans = total
for k in range(K, N):
    exp = exps[P[k]]
    head = heads.popleft()
    heads.append(exp)
    total = total - head + exp
    ans = max(ans, total)

print(ans)

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

template <class T> struct BIT {
  int n;
  vector<T> bit;

  BIT(int node) : n(node), bit(node + 1, 0) {}

  void init(int node = -1) {
    if(node != -1) n = node;
    bit.clear();
    bit.resize(n + 1, 0);
  }

  inline T sum(int i) {
    T s = 0;
    while(i > 0) {
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }

  inline T sum(int a, int b) {
    return sum(b) - sum(a - 1);
  }

  inline void add(int i, T x) {
    while(i <= n) {
      bit[i] += x;
      i += i & -i;
    }
  }

  int get(long long k) {
    ++k;
    int res = 0;
    int N = 1;
    while(N < bit.size()) N *= 2;
    for(int i = N / 2; i > 0; i /= 2) {
      if(res + i < bit.size() && bit[res + i] < k) {
        k -= bit[res + i];
        res += i;
      }
    }
    return res + 1;
  }
};

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

  int n, q;
  cin >> n >> q;
  BIT<i64> bit0(n), bit1(n);
  rep(i, 0, q) {
    int query, s, t;
    cin >> query >> s >> t;
    if(query) {
      i64 res = 0;
      res += bit0.sum(t) + bit1.sum(t) * t;
      res -= bit0.sum(s - 1) + bit1.sum(s - 1) * (s - 1);
      cout << res << endl;
    }
    else {
      i64 x;
      cin >> x;
      bit0.add(s, -x * (s - 1));
      bit1.add(s, x);
      bit0.add(t + 1, x * t);
      bit1.add(t + 1, -x);
    }
  }
}



Measured memory_bytes: 4412
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a, b;
    scanf("%d %d",&a,&b);
    if(a>b)
    {
        printf("a > b\n");
    }
    else if(a<b)
        printf("a < b\n");
    else
        printf("a == b\n");
    return 0;
}



Measured memory_bytes: 2588
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;

double cross(P a, P b){
    return (conj(a)*b).Y;
}
bool in_tri(const P& p, const VP& tri){
    return cross(tri[1]-tri[0], p-tri[0])>0 &&
        cross(tri[2]-tri[1], p-tri[1])>0 &&
        cross(tri[0]-tri[2], p-tri[2])>0;
}

int main(){
    int n;
    cin >> n;
    for(int i=0; i<n; i++){
        VP tri(3);
        for(int j=0; j<3; j++){
            int x,y;
            cin >> x >> y;
            tri[j] = P(x,y);
        }
        if(cross(tri[1]-tri[0], tri[2]-tri[0])<0){
            swap(tri[1], tri[2]);
        }
        VP sg(2);
        for(int j=0; j<2; j++){
            int x,y;
            cin >> x >> y;
            sg[j] = P(x,y);
        }
        if(in_tri(sg[0], tri) != in_tri(sg[1], tri)){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }
    return 0;
}



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

int main() {
  int N;
  cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
    a.at(i)--;
  }
  int ans=0;
  for(int i=0;i<N;i++){
    if(a.at(a.at(i))==i)
      ans++;
  }
  cout<<ans/2<<endl;
}


Measured memory_bytes: 3764