akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

struct Union_Find_Tree {
private:
	vector<ll>par;
	vector<ll>Rank;
	int N;
public:
	void init(int n) {
		N = n;
		par.resize(N + 1);
		Rank.resize(N + 1);
		for (int i = 0;i <= N;i++)par[i] = i, Rank[i] = 0;
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (Rank[x] < Rank[y])par[x] = y;
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};


int n, m, k, a, b, c;
int d[100010], belong_par[1000010];
vector<int>v[100010];



int main() {
	cin >> n >> m >> k;
	Union_Find_Tree uf;
	uf.init(n);
	for (int i = 0;i < n;i++) {
		belong_par[i] = -1;
	}
	for (int i = 1;i <= k;i++) {
		cin >> a >> b >> c;
		a--;
		if (!a) {
			b--, c--;
			if (belong_par[uf.find(b)] == belong_par[uf.find(c)])uf.unite(b, c);
			else if (belong_par[uf.find(b)] == -1 && belong_par[uf.find(c)] == -1)uf.unite(b, c);
			else if (belong_par[uf.find(b)] == -1 && belong_par[uf.find(c)] != -1) {
				belong_par[uf.find(b)] = belong_par[uf.find(c)];
				uf.unite(b, c);
			}
			else if (belong_par[uf.find(b)] != -1 && belong_par[uf.find(c)] == -1) {
				belong_par[uf.find(c)] = belong_par[uf.find(b)];
				uf.unite(b, c);
			}
			else {
				cout << i << endl;
				return 0;
			}
		}
		else {
			b--;
			if (belong_par[uf.find(b)] == -1)belong_par[uf.find(b)] = c;
			else if (belong_par[uf.find(b)] != c) {
				cout << i << endl;
				return 0;
			}
		}
	}
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 7060
// Created by abhay
#include <bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define allc c.begin(),c.end()
#define tr(c,i) for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) (c.find(x) != c.end())
#define cpresent(c,x) (find(allc,x) != c.end())
#define rep(i,n) for(int i=0;i<(n);++i)
#define ll long long
const double pi=3.14;
using namespace std;

int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll r;
	cin>>r;
	cout<<setprecision(6)<<(2*pi*r);
}


Measured memory_bytes: 3804
#include <iostream>
#include <set>

using namespace std;

int main()
{
	int n, k, a[11], b[11];
	while(1)
	{
		set<int> s;
		cin >> n >> k;
		if(n==0 && k==0) break;
		else
		{
			for(int i=0; i<n; i++)
			{
				cin >> a[i];
				if(a[i]>9) b[i]=2;
				else b[i]=1;
			}
			for(int i=0; i<n; i++)
			{
				int x=0;
				x=a[i];
				x*=10;
				for(int j=0; j<n; j++)
				{
					int y=x;
					if(j==i) continue;
					if(b[j]==2) y*=10;
					y+=a[j];
					if(k==2) s.insert(y);
					y*=10;
					for(int l=0; l<n; l++)
					{
						int z=y;
						if(l==i || l==j) continue;
						if(b[l]==2) z*=10;
						z+=a[l];
						if(k==3) s.insert(z);
						z*=10;
						for(int m=0; m<n; m++)
						{
							int w=z;
							if(m==i || m==j || m==l) continue;
							if(b[m]==2) w*=10;
							w+=a[m];
							if(k==4) s.insert(w);
						}
					}
				}
			}
			cout << s.size() << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int64_t X, Y;
    cin >> X >> Y;

    int64_t ans = 0;
    for (int64_t j = X; j <= Y; j = j * 2) {
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

ll gcd(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
}

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

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

    vector<int> L(N);
    REP(i,N){
        cin >> L[i];
    }

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

    int sum = accumulate(L.begin(), L.end()-1, 0);

    /*REP(i,N){
        cout << L[i] << endl;
    }

    cout << sum << endl;
    cout << L[L.size()-1] << endl;*/

    if(sum>L[L.size()-1]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
S=input();T=input()
N=len(S);NP=len(T);M=len(T)
for i in range(N-M+1):
  cnt=0
  for j in range(M):
    if T[j]==S[j+i]:cnt+=1
  if NP>M-cnt: NP=M-cnt
print(NP)

Measured memory_bytes: 9052
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
	ios::sync_with_stdio(0);
	cout << setprecision(10) << fixed;
	map<string , string> wea;
	wea["Sunny"] = "Cloudy";
	wea["Cloudy"] = "Rainy";
	wea["Rainy"] = "Sunny";
	string s;
	cin >> s;
	cout << wea[s];
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

/*template*/

ll x[200001] = {};
ll y[200001] = {};
int main() {
	ll N; cin >> N;
	repe(i, 1, N) {
		cin >> x[i];
		y[i] = x[i];
	}

	sort(y, y + N + 1);
	ll r = y[N / 2 + 1];
	ll l = y[N / 2];

	repe(i, 1, N) {
		if (x[i] <= l) cout << r << endl;
		else cout << l << endl;
	}

	return 0;
}

Measured memory_bytes: 5376
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz");
char s[10][10];
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> h >> w >> k;
  rep(i, h) rep(j, w) cin >> s[i][j];
  for (int bit = 0; bit < (1 << h); bit++) {
    ll yoko[10] = {};
    rep(i, h) {
      if (bit & (1 << i)) {
        yoko[i] = 1;
      }
    }
    for (int bit2 = 0; bit2 < (1 << w); bit2++) {
      ll tate[10] = {};
      rep(i, w) {
        if (bit2 & (1 << i)) {
          tate[i] = 1;
        }
      }
      cnt = 0;
      rep(i, h) {
        rep(j, w) {
          if (yoko[i] || tate[j]) continue;
          if (s[i][j] == '.') continue;
          cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  Cout(ans);
  return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int a, b, h, flag = 1;;
    cin >> a;
    if(a<1 || a>100) flag =0;
    cin >> b;
    if(b<1 || b>100) flag = 0;
    cin >> h;
    if(h<1 || h>100 || (h%2 != 0)) flag = 0;
    if(flag)
    {
        cout << (a+b)*h/2;
    }
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<map>
#include<vector>
#include<cmath>
#include<string>
#include<algorithm> 
using namespace std;
 
# define p(s) std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
 
int getKeta(long long int a){
    int c=0;
    while(a>0){
        c++;
        a/=10;
    }
    return c;
}

int main()
{
    long long int n;cin >> n;
    int ans=getKeta(n);
    for(long long int i=1;i<=(long long int)sqrt(n);i++){
        if(n%i==0) ans = min(getKeta(n/i),ans);
    }
    p(ans)
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int N;
vector<vector<PII>> E;
vector<int> Ans;
vector<bool> visited;


void dfs(int f, int x){
    visited[x] = true;
    Ans[x] = f;
    for(int i=0; i<E[x].size(); i++){
        int nx = E[x][i].fs;
        int cost = E[x][i].sc;
        if(!visited[nx]){
            if(cost % 2 == 0) dfs(f, nx);
            else dfs(f^1, nx);
        }
    }
    return;
}


int main() {
    cin >> N;
    E.resize(N);
    Ans.resize(N);
    visited.resize(N);
    for(int i=0; i<N-1; i++){
        int u, v, w; cin >> u >> v >> w;
        E[u-1].push_back({v-1, w});
        E[v-1].push_back({u-1, w});
    }
    
    dfs(0, 0);
    for(int i=0; i<N; i++){
        cout << Ans[i] << endl;
    }
    return 0;
}



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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

vi prime(int n){
  // n以下の素数を要素に持つviを返す
  // 時間 O(n ln ln n)
  // 答えのサイズ n / ln n

  vector<bool> isprime(n+1,true);
  vi ans;
  isprime[0] = isprime[1] = false;
  FOR(i,2,n+1)
    if(isprime[i]){
      ans.pb(i);
      for(int j = 2 * i; j <= n; j += i) isprime[j] = false;
    }
  return ans;
}

main(){
  vi p = prime(123456 * 2);

  while(1){
    int n; cin >> n; if(n == 0) break;

    auto l = upper_bound(all(p),n);
    auto r = upper_bound(all(p),2*n) - 1;
    cout << r - l  + 1<< endl;
  }
}


Measured memory_bytes: 3220
import java.util.Scanner;

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

	int L = 0;
	int R = 0;
	int Lmax = 0;
	int Rmin = N;
	for(int i=0;i<M;i++){
	    L = sc.nextInt();
	    R = sc.nextInt();
	    if(L > Lmax) Lmax=L;
	    if(R < Rmin) Rmin=R;
	}
	if(Lmax <= Rmin) System.out.print(Rmin -Lmax +1);
	else System.out.print(0);
    }
}


Measured memory_bytes: 61636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,x,i,j,k,cnt;
  while(1){
    cnt=0;
    cin >> n >> x;
    if(n==0&&x==0) break;
    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	for(k=1;k<=n;k++){
	  if(i!=j&&j!=k&&k!=i&&i+j+k==x) cnt++;
	}
      }
    }
    cout << cnt/6 << endl;
  }
  return 0;
}



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

#define IOS ios::sync_with_stdio(false); cin.tie(0);



int main(void)
{
    IOS
    int n;
    string s;

    cin >> n;
    cin >> s;

    int white = 0;
    int black = 0;
    int sleft = 0;  // #left
    int dleft = 0;  // .left


    int len = s.size();
    if (len == 1) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = 0 ; i < len; i++) {
        if (s[i] == '.'){
            if ((i > 0) && (s[i-1] == '#')){
                dleft = min({black,white,sleft,dleft});
            }
            dleft++;
            white++;
            sleft = black;
        } else if (s[i] == '#'){
            if ((i > 0) && (s[i-1] == '.')){
                sleft = min(black,white);
            }
            black++;
        }
    }
    int ans = min({white,black,sleft,dleft});
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 720
N=int(input())
*A,=sorted(map(int,input().split()))

f=lambda:2**(N//2)%(10**9+7)
a=True
if N%2==0:
    for i in range(1,N,2):
        if A[i-1]!=i or A[i]!=i:
            # print(i,A[i-1],A[i])
            a=False
            break
else:
    if A[0]!=0:
            a=False
    else:
        for i in range(2,N,2):
            if A[i-1]!=i or A[i]!=i:
                # print(i,A[i-1],A[i])
                a=False
                break
print(f() if a else 0)

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

using namespace std;

int main() {
  string S, T;
  cin >> S >> T;
  for (int i = 0; i < S.length(); i++) {
    string A = S.substr(i) + S.substr(0, i);
    if (A == T) {
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;

ll powmod(ll a, ll b, ll MOD = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (MOD - 1ll), a %= MOD;
	while(b){
		if(b%2 == 1)	res = (res * a) % MOD;
		a = (a * a) % MOD;
		b /= 2;
	}
	return res;
}

ll dp[1010][20010];	

struct node {
	ll w, s, v;
};

int main(){	

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	cin >> n;

	node arr[n];

	for(int i = 0; i < n; i++){
		cin >> arr[i].w >> arr[i].s >> arr[i].v;
	}

	sort(arr, arr + n, [](node a, node b) -> bool {
		return (a.s + a.w) < (b.s + b.w);
	});

	for(int j = 0; j <= 10000; j++)	dp[0][j] = -INF;
	dp[0][0]=0;

	ll ans = 0;

	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= 20000; j++){
			dp[i][j] = dp[i-1][j];
			if((j - arr[i - 1].w) >= 0 and (j - arr[i - 1].w) <= arr[i - 1].s){
				dp[i][j] = max(dp[i][j], dp[i-1][j - arr[i - 1].w] + arr[i - 1].v);
			}
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans << "\n";
	
}

Measured memory_bytes: 157952
#include <stdio.h>
int main(){
  int n,q,S[10000],T[500],i,j,count=0,a[10000],k;
  scanf("%d",&n);
  for(i=0;i<n;i++)
	scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
	scanf("%d",&T[i]);
  for(i=0;i<q;i++){
	for(j=0;j<n;j++){
	  if(S[j]==T[i]){//同じ数を発見
		count++;
		break;
	  }
	}
  }
  printf("%d",count);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
min_y = min(y)
flag = False
for Z in range(X + 1, Y + 1):
    if max_x < Z and min_y >= Z:
        flag = True
print('No War' if flag else 'War')

Measured memory_bytes: 3064
a,b,c,d = map(int,list(input()))
for i in range(2):
    if i==0:
        ans=a+b
    else:
        ans=a-b
    r1=ans
    for j in range(2):
        ans=r1
        if j==0:
            ans+=c
        else:
            ans-=c
        r2=ans
        for k in range(2):
            ans=r2
            if k==0:
                ans+=d
            else:
                ans-=d
            if ans==7:
                ret=[i,j,k]
                for i in range(len(ret)):
                    if ret[i]==0:
                        ret[i]='+'
                    else:
                        ret[i]='-'
                print('{}{}{}{}{}{}{}=7'.format(a,ret[0],b,ret[1],c,ret[2],d))
                exit()

Measured memory_bytes: 3064
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint a[5];

int main(void)
{
	cin >> n;
	for(int i = 0; i < 5; i++) cin >> a[i];
	
	llint neck = 1e16;
	for(int i = 0; i < 5; i++) neck = min(neck, a[i]);
	cout << 4 + (n+neck-1)/neck << endl;
	return 0;
}

Measured memory_bytes: 256
/*map,set,priority_queue,stack,queue*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define el "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
typedef vector<int> vi;
const int inf = (1e18)+7;
const int neginf = -1*((int)1e18 ) + 7 ;
const int mod = (int)1e9 + 7;
//const int N = 500007;
/*int arr[N];
vector<int> adj[N];

void dfs(int x,int par)
{
    arr[x]+=par;
    arr[par] = 0;
    for(auto child:adj[x])
    {
        if(child==par)
            continue;
        dfs(child,x);
    }
}
*/

int32_t main() 
{
fastio
    int t=1;
    //cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
      set<int> st;
        for(int i=1;i<=9;++i)
        {
            for(int j=1;j<=9;++j)
                st.insert(i*j);
        }
        if(st.find(n)!=st.end())
            cout<<"Yes";
        else
            cout<<"No";
        
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    a, b, c, d = MI()
    temp = [a*c, a*d, b*c, b*d]
    ans = max(temp)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9184
#imsosorryididntwanttoimplementmodpow
import math
n,m = [int(x) for x in input().split()]

def comb(n, r):
    return math.factorial(n) // (math.factorial(n-r)*math.factorial(r))

i = 2
ans = 1
while (i<=m):
    if m%i==0:
        mult = 0
        while (m%i==0):
            mult += 1
            m //= i
        ans *= comb(n+mult-1,n-1)
    i += 1
if m!=1:
    ans *= comb(n,n-1)

print(ans%int(1e9+7))


Measured memory_bytes: 114396
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
int gcd(int a, int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    int N;
    bool d[102]={false};
    int ans=0;

    cin >> N;
    rep(i,N){
        int mochi_size;
        cin >> mochi_size;
        d[mochi_size]=true;
    }

    rep(i,101){
        if(d[i])
            ans++;
    }

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



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <functional>
#include "math.h"
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<long long int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MB 1000000007
#define NB 1000000000
#define ll long long int
int H,N;
VI A;

int main()
{

	cin >> H >> N;
	A.resize(N);
	ll ans = 0;
	REP(i,N){
		cin >>A[i];
		ans += A[i];
	}
	if(ans < H){
		cout << "No";
	} else {
		cout << "Yes";
	}

}







Measured memory_bytes: 1024
using System;
using System.IO;

class Solve{
    static void Main(string[] args){
        long H = long.Parse(Console.ReadLine());
        long answer = 1;
        int index = 1;
        while (H > 1){
            answer += (long)Math.Pow(2, index++);
            H /= 2;}
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

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

int main()
{
  int n,a,b;
  string str,ch,p;
  char c;
  cin>>str;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>ch;
    if(ch=="replace"){
      cin>>a>>b>>p;
      for(int j=a,k=0;j<=b;j++,k++)str[j]=p[k];
    }
    if(ch=="reverse"){
      cin>>a>>b;
      for(int j=a,k=b;j<(a+b+1)/2;j++,k--){
	swap(str[j],str[k]);
      }
    }
    if(ch=="print"){
      cin>>a>>b;
      for(int j=a;j<b+1;j++)cout<<str[j];
      cout<<endl;
    }
  }
  return 0;
}


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

int main() {
  long long N, a;
  cin >> N;
  a = (long long)sqrt((double) N);
  while (N%a != 0) {
    a--;
  }
  cout << a + N/a - 2 << endl;
}


Measured memory_bytes: 256
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

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

        final long W = sc.nextLong();
        final long H = sc.nextLong();
        final long X = sc.nextLong();
        final long Y = sc.nextLong();

        System.out.printf("%f %d\n", W * H / 2.0, 2 * X == W && 2 * Y == H ? 1 : 0);
    }
}


Measured memory_bytes: 23892
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<map>
#include<queue>
#include<vector>
#include<stack>
#include<set>
#define pa pair<int,int>
#define INF 0x3f3f3f3f
#define inf 0x3f
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define pb push_back

using namespace std;

inline ll read()
{
	long long f=1,sum=0;
	char c=getchar();
	while (c<'0' || c>'9')
	{
		if (c=='-')	f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9')
	{
		sum=sum*10+c-'0';
		c=getchar();
	}
	return sum*f;
}

int main()
{
	int n,k;
	scanf("%d%d",&n,&k);
	ll ans=0;
	if (!k)
	{
		cout<<(ll)n*n;
		return 0;
	}
	for (int b=k+1;b<=n;b++)
	{
		int t=n/b;
		ans+=(b-k)*t;
		int l=n-b*t;
		ans+=max(0,l-k+1);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
	string s;
	int k;
	cin >> s >> k;
	for(int i=0; i<s.size(); i++){
		if(i == s.size()-1){
			s.at(i) = (((s.at(i) - 'a') + k) % 26) + 'a';
			k = 0;
		}else if(26 - (s.at(i) - 'a') <= k && s.at(i) != 'a'){
			k -= 26 - (s.at(i) - 'a');
			s.at(i) = 'a';
		}
	}
	cout << s << endl;
	return 0;
}

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

int main(){
  int N,X,sum = 0;
  cin >> N >> X;
  int a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a,a+N);
  cout << (X-sum)/a[0] + N << endl;        
}

Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()    
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    vector<string> vs = {"Sunny", "Cloudy", "Rainy", "Sunny"};
    string s; cin >> s;
    rep(i,3){
        if(s == vs[i]){
            cout << vs[i+1] << '\n';
            return 0;
        }
    }
}


Measured memory_bytes: 3648
import sys
sys.setrecursionlimit(10**7)
import math
mod = 10**9 + 7
def I(): return int(input())
def II(): return map(int, input().split())
def L(): return list(map(int, input().split()))
def TWO(M):
  L=[0]*M
  R=[0]*M
  for i in range(M):
    L[i],R[i] = II()
  return L, R

r = I()
print(3*r**2)

Measured memory_bytes: 38384
import Control.Applicative
main = do
    answer <- (swap . map read . words) <$> getLine
    swappingTwoNumbers answer

swappingTwoNumbers :: String -> IO ()
swappingTwoNumbers "" = putStr ""
swappingTwoNumbers answer = do
    putStrLn answer
    next <- (swap . map read . words) <$> getLine
    swappingTwoNumbers next

swap :: [Int] -> String
swap [0, 0] = ""
swap [a, b] | a <= b = show(a) ++ " " ++ show(b)
            | otherwise = show(b) ++ " " ++ show(a)

Measured memory_bytes: 4000
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>

int main(void) {
	int n, k;

	std::cin >> n >> k;

	int count = 0;
	for (size_t i = 1; i <= n; i+= 2) {
		count++;
	}

	if (count >= k) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define REP(i,n) for (int i=1;i<=(n);i++)
typedef long long ll;
 
int main() {
    vector<vector<int>> a(3,vector<int> (3,0));
    rep(i,3) rep(j,3) cin >> a[i][j];
    int n;
    cin >> n;
    rep(i,n){
        int b;
        cin >> b;
        rep(j,3) rep(k,3) if(a[j][k] == b) a[j][k] = 0;
    }
    bool ans = false;
    rep(i,3){
        if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0) ans=true;
        if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0) ans=true;
    }
    if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0) ans = true;
    if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0) ans = true;    
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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


const long long INF = 1LL << 60;

using namespace std;
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; }

template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;

int N;
vector<vector<int> > G;
mint dp[110000][2]; // dp[i][j] : 頂点iをjで塗った時の、下位の部分木の塗り方の組み合わせ
bool ischecked[110000][2] = {false};

mint rec(int v, int color, int parent = -1){
    if(ischecked[v][color]) return dp[v][color];
    ischecked[v][color] = true;
    mint ret = 1; // とりあえず１通り
    for(auto nv : G[v]){
        if(nv != parent){ // 辿ってきた方向には戻らない
            if(color==0){
                ret *= rec(nv,0,v) + rec(nv,1,v); // vを白で塗る場合、nvを白でも黒でも塗れる。
            } else {
                ret *= rec(nv,0,v); // vを黒で塗る場合、nvは白でしか塗れない。
            }
        }
    }
    return dp[v][color] = ret;
}

int main() {
    cin >> N;
    G.assign(N,vector<int>());
    for(int i=0;i<N-1;++i){
        int from, to;
        cin >> from >> to;
        from--;to--;
        G[from].push_back(to);
        G[to].push_back(from);
    }



    mint ans = rec(0,0) + rec(0,1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15104
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main(void) {
   char X, Y;
   scanf("%c %c", &X, &Y);
   if (X < Y) {
      printf("<\n");
   } else if (X > Y) {
      printf(">\n");
   } else {
      printf("=\n");
   }
   return 0;


}


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


 int main()
 {
 	int a,b,c;
 	scanf("%d %d %d", &a,&b,&c);
 	
 
 	
 	if(a > b )
 	{
		 int temp=a;
		 a=b;
		 b=temp;
	 }
	  	if(a> c )
 	{
		 int temp=a;
		 a=c;
		 c=temp;
	 }
	  	if(b >c)
 	{
		 int temp=b;
		 b=c;
		 c=temp;
	 }
	 printf("%d %d %d\n",a, b, c);
	 
    
 	return 0;
 }


Measured memory_bytes: 2688
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int n = sc.nextInt();
		Work[] works = new Work[n];
		for(int i = 0; i < n; i++) {
			works[i] = new Work(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(works);
		int now = 0;
		for(int i = 0; i < n; i++) {
			now += works[i].c;
			if(now > works[i].l) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
	
	class Work implements Comparable<Work>{
		int c, l;//cost, limit
		Work(int cost, int limit) {
			c = cost; l = limit;
		}
		@Override
		public int compareTo(Work arg0) {
			if(this.l != arg0.l) {
				return (this.l < arg0.l)?-1:1;
			}
			else if(this.c != arg0.c) {
				return (this.c < arg0.c)?-1:1;
			}
			return 0;
		}
	}

	long gcd(long a, long b) {
		long w;
		while(b != 0) {
			w = a % b;
			a = b;
			b = w;
		}
		return a;
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 103512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
using namespace std;
struct info
{
    int l,r,d;
}s[400005];
int n,m;
int flag = 1;
int dis[100005],visited[100005];
int first[400005],nexti[400005];
void dfs(int t)
{
    if(!flag)return;
    int k = first[t];
    while(k != -1)
    {
        if(!flag)return;
        if(!visited[s[k].r])
        {
            dis[s[k].r] = dis[s[k].l] + s[k].d;
            visited[s[k].r] = 1;
            dfs(s[k].r);
        }
        else if(s[k].d != (dis[s[k].r] - dis[s[k].l]))
        {
            flag = 0;
            return;
        }
        k = nexti[k];
    }
}
int main()
{
    scanf("%d%d",&n,&m);
    memset(first,-1,sizeof(first));
    for(int i = 0;i < m;i ++)
    {
        scanf("%d%d%d",&s[i].l,&s[i].r,&s[i].d);
        nexti[i] = first[s[i].l];
        first[s[i].l] = i;
        s[i + m].r = s[i].l;
        s[i + m].l = s[i].r;
        s[i + m].d = -s[i].d;
        nexti[i + m] = first[s[i + m].l];
        first[s[i + m].l] = i + m;
    }
    for(int i = 1;i <= n;i ++)
    {
        if(!flag)break;
        if(!visited[i])
        {
            visited[i] = 1;
            dfs(i);
        }
    }
    if(flag)printf("Yes");
    else printf("No");
}


Measured memory_bytes: 9728
n = int(input())
num = [int(i) for i in input().split()]
count1 = 0
minv = 0

for i in range(len(num)):
    if i ==0:
        count1 +=1
        minv = num[i]
        
    elif minv >= num[i]:
        minv = num[i]
        count1 +=1
print(count1)

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

int main(){
  int n,p;
  cin >> n >> p;
  vector<int> A(n+10);
  bool flag = true;
  ll ans;
  rep(i,n){
    cin >> A[i];
    if(A[i]%2 == 1) flag = false;
  }
  if(flag){
    if(p == 0) ans = pow(2,n);
    else ans = 0;
  }
  else{
    ans = pow(2,n-1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
from heapq import heappush, heappop
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy4, dx4 = [0, -1, 0, 1], [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def ceil(a, b): return (a + b - 1) // b


def main():
    N = int(input())
    a = Counter(list(map(int, input().split())))

    ans = 0
    for k, v in a.items():
        if k == v:
            continue
        elif k < v:
            ans += v - k
        else:
            ans += v
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(a*b,c*d)<<endl;
  return(0);
}


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

int main()
{
    int a, b;
    cin >> a >> b ;
	int x = (a + b ) % 2;

	cout <<  (((x == 0) ? (a + b) / 2 : (a + b) / 2 + 1))  << "\n";
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDivideTheProblems solver = new CDivideTheProblems();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDivideTheProblems {
        PrintWriter out;
        InputReader in;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.out = out;
            this.in = in;
            int n = ni();
            int[] arr = new int[n];
            int i = 0;
            for (i = 0; i < n; i++)
                arr[i] = ni();
            sort(arr);
            int mid = arr[n / 2] - arr[n / 2 - 1];
            pn(mid);
        }

        void sort(int[] A) {
            PriorityQueue<Integer> pq = new PriorityQueue();
            int i = 0;
            for (i = 0; i < A.length; i++)
                pq.add(A[i]);
            for (i = 0; i < A.length; i++)
                A[i] = pq.poll();
        }

        int ni() {
            return in.nextInt();
        }

        void pn(long zx) {
            out.println(zx);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	cin >> N;
	llong i = 1;
	while(i*i <= N)
		i++;

	cout << (i-1)*(i-1) << endl;

	return 0;
}

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

using namespace std;

string s;

int main(void)
{
	cin >> s;
	
	int cnt = 0, ans = 0, len = 2;
	for(int i = 0; i < s.size(); i++){
		if(len == 2){
			len = 1;
			ans++;
		}
		else{
			if(s[i-1] != s[i]) len = 1, ans++;
			else{
				if(i < (int)s.size()-1){
					len = 2;
					ans++;
					i++;
				}
			}
				
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    cnt = 0

    for i in A:
        if i/sum(A) >= 1/(4*M):
            cnt += 1
    if cnt >= M:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 9052
#入力
N,M=map(int,input().split())
H=list(map(int,input().split()))

#隣接展望台の最大標高リスト初期化
road_max=[0 for l in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    if road_max[a-1]<H[b-1]:
        road_max[a-1]=H[b-1]
    if road_max[b-1]<H[a-1]:
        road_max[b-1]=H[a-1]

result=[(road_max[p]<H[p])*1 for p in range(N)]

print(sum(result))

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

int main(){
    int N;
    long K;
    cin >> N >> K;
    int A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    unsigned long sum=0;
    int alpha[N]={0};
    int beta[N]={0};
    unsigned long moder=10*10*10*10*10*10*10*10*10 + 7;
    for(int i=0;i<N;i++){
        for(int j=0;j<i;j++){
            if(A[j]<A[i]){
                alpha[i]++;
            }
        }
        for(int j=i+1;j<N;j++){
            if(A[j]<A[i]){
                beta[i]++;
            }
        }
    }
    unsigned long muti=K*(K-1);
    muti=muti/2;
    muti=muti%moder;
    for(int i=0;i<N;i++){
        unsigned long P=K*beta[i]+(alpha[i]+beta[i])*muti;
        sum+=P%moder;
    }
    cout << sum % moder;
    return 0;
}

Measured memory_bytes: 384
# https://atcoder.jp/contests/abc054/tasks/abc054_a
# A - One Card Poker
a, b = list(map(int, input().split()))

if a == 1:
    a = 100
if b == 1:
    b = 100

if a == b:
    answer = 'Draw'
elif a < b:
    answer = 'Bob'
elif a > b:
    answer = 'Alice'

print(answer)


Measured memory_bytes: 2940
import numpy as np
N, S = list(map(int, input().split()))
a = list(map(int, input().split()))

mod = 998244353


dp = np.zeros(S+1)

dp[0] = 1

for i in range(N):
    tmp = dp*2
    tmp[a[i]:] += dp[:-a[i]]
    dp = tmp % mod

print(int(dp[S]))

Measured memory_bytes: 27308
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

void tolower(char str[]) {
	for (int i = 0; i < strlen(str); i++) {
		str[i] = tolower(str[i]);
	}
}

int main() {

	char w[11];
	scanf("%s", w);
	tolower(w);

	int count = 0;

	while (1) {
		char t[1001];
		scanf("%s", t);
		if (strcmp(t, "END_OF_TEXT") == 0) {
			break;
		}
		tolower(t);

		if (strcmp(w, t) == 0) {
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 1160
import sys

MOD = 10 ** 9 + 7

n, a, b = map(int, sys.stdin.readline().split())
k = min(n, 2 * 10 ** 5)

def make_inv(size=10**6, p=MOD):
    fac = [None] * (size + 1)
    fac[0] = 1
    for i in range(size):
        fac[i+1] = fac[i] * (i + 1) % p
    ifac = [None] * (size + 1)
    ifac[size] = pow(fac[size], p-2, p)
    for i in range(size, 0, -1):
        ifac[i-1] = ifac[i] * i % p
    inv = [None] * (size + 1)
    for i in range(1, size+1):
        inv[i] = fac[i-1] * ifac[i] % MOD
    return inv

inv = make_inv(k)

def make_table(n, k, p=MOD):
    table = [None] * (k + 1)
    table[0] = 1
    for i in range(k):
        table[i+1] = table[i] * (n - i) % MOD * inv[i+1] % MOD
    return table

comb_n = make_table(n, k)

def main():
    res = pow(2, n, MOD) - comb_n[a] - comb_n[b] - 1
    return res % MOD

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 26740
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;
int a[21],b[21],c[21],n;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];
    for(int i=1;i<n;i++)cin>>c[i];
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        sum+=b[a[i]];
        if(a[i+1]==a[i]+1&&i<=n)sum+=c[a[i]];
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 2e5 + 5, inf = 1e18, mod = 1e9 + 7;

int n, a[N];

void solve();

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

void solve(){
    int ans = inf;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    for(int i = -200; i <= 200; i++){
        int cost = 0;
        for(int j = 1; j <= n; j++)
            cost += (a[j] - i) * (a[j] - i);
        ans = min(ans, cost);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(' ').map { it.toInt() }

    var ans = 0

    fun dfs(xs: IntArray, cur: Int) {
        if (cur == n) {
            if (a.mapIndexed { i, v -> v + xs[i] }.any { it and 1 == 0 }) ans++
            return
        }
        dfs(xs.plus(-1), cur + 1)
        dfs(xs.plus(0), cur + 1)
        dfs(xs.plus(1), cur + 1)
    }

    dfs(IntArray(0), 0)

    println(ans)
}


Measured memory_bytes: 48688
n = int(input())
a, b = map(int, input().split())
p = list(map(int, input().split()))
# print(a, b, p, sep='\n')

first = []
second = []
final = []

for ele in p:
    if ele <= a:
        first.append(ele)
    elif ele <= b:
        second.append(ele)
    else:
        final.append(ele)

print(min(len(first), len(second), len(final)))

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();


	int n; cin >> n;
	vector<int>A(1e5 + 5, 0);
	vector<int>B(1e5 + 5, 0);
	rep(i, n) {
		int x;
		cin >> x;
		if (i % 2 != 0) A.at(x)++;
		else B.at(x)++;
	}
	int odd = 0, odd2 = 0, even = 0, even2 = 0;
	int x, y;
	rep(i, 1e5 + 5) {
		if (odd < A[i])x = i;
		if (even < B[i])y = i;
		odd = max(odd, A[i]);
		even = max(even, B[i]);
	}
	sort(all(A));
	reverse(all(A));
	sort(all(B));
	reverse(all(B));
	int ans;
	if (x != y)ans = n - A[0] - B[0];
	else ans = min(n - A[1] - B[0], n - A[0] - B[1]);
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,m;string s;
    cin >> n >> m >> s;
    int pos = n;
    bool ok = true;
    stack<int> ans;
    while(pos!=0){
        int k=0;
        for(int j=1;j<=m && pos-j>=0;++j){
            if(s[pos-j]=='0') k = j;
        }
        if(k==0){
            ok = false;
            break;
        }
        ans.push(k);
        pos -= k;
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    while(ans.size()){
        cout << ans.top() << endl;
        ans.pop();
    }
}

Measured memory_bytes: 876
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int all = scanner.nextInt();
        int num = scanner.nextInt();

        ArrayList<Integer> priceList = new ArrayList<>();
        for(int i = 0; i < all; i++) {
            priceList.add(scanner.nextInt());
        }
        Collections.sort(priceList);
        int cost = 0;
        for (int i = 0; i < num; i++) {
            cost += priceList.get(i);
        }
        System.out.println(cost);
    }
}

Measured memory_bytes: 38712