akhauriyash/Code-Regression huggingface dataset:
from heapq import heappush, heappop, heappushpop
N = int(input())
*A, = map(int, input().split())

def update(v, que):
    p, q = que
    if v == p or v == q:
        return
    heappushpop(que, v)

memo = [None]*(2**N)
memo[0] = [(0, -1), (A[0], 0)]
ma = 0; ans = []
for i in range(1, 2**N):
    res = [(0, -1), (A[i], i)]
    for j in range(N):
        if (i >> j) & 1 == 0:
            continue
        p, q = memo[i ^ (1 << j)]
        update(p, res)
        update(q, res)
    p, q = memo[i] = res
    ma = max(ma, p[0] + q[0])
    ans.append(ma)
print(*ans, sep='\n')


Measured memory_bytes: 122544
#include <stdio.h>

int w1, w2, w3;

int is_rect(void){
	return w3*w3 == w1*w1 + w2*w2;
}

int is_hishi(void){
	return w1 == w2;
}

int main(void){
	int cr = 0, ch = 0;
	while(scanf("%d,%d,%d", &w1, &w2, &w3) != EOF){
		cr += is_rect();
		ch += is_hishi();
	}
	printf("%d\n%d\n", cr, ch);
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define PI 3.1415926535897932
#define MOD 1000000007;
using namespace std;
long long GCD(long long A,long long B){
  if(B==0){
    return A;
  }
  else{
    return GCD(B,A%B);
  }
}
long long LCM(long long A,long long B){
  long long g=GCD(A,B);
  return A/g*B;
}
long long num_order(long long X){
  long long ans=0;
  while(true){
    if(X==0){
      break;
    }
    else{
      X/=10;
      ans++;
    }
  }
  return ans;
}

vector<pair<long long,long long>> prime_factorize(long long N){
  vector<pair<long long,long long>> res;
  
  for(long long i=2;i*i<=N;i++){
    if(N%i!=0){
    continue;
    }
    
    long long ex=0;
    while(N%i==0){
      ex++;
      N/=i;
    }
    
    res.push_back({i,ex});
  }
  
  if(N!=1){
  res.push_back({N,1});
  }
  
  return res;
}


int main() {
  
  long long A,B,C,D;
  cin>>A>>B>>C>>D;
  
  long long ans;
  
  if(B<0){
    if(C<0){
      ans=A*C;
    }
    else{
      ans=B*C;
    }
  }
  else if(B>=0&&A<=0){
    if(D<0){
      ans=A*C;
    }
    else if(D>=0&&C<=0){
      ans=max(A*C,B*D);
    }
    else if(C>0){
      ans=B*D;
    }
  }
  else if(A>0){
    if(D<0){
      ans=A*D;
    }
    else{
      ans=B*D;
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

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

int H, W;
char m[50][50];
int dist[50][50];

int main() {
  cin >> H >> W;
  rep(i, H) {
    rep(j, W) {
      cin >> m[i][j];
    }
  }

  queue<pair<int, int>> que;
  que.push(make_pair(0, 0));

  dist[0][0] = 1;

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

  while(que.size()) {
    pair<int, int> p = que.front();
    que.pop();
    int x = p.first;
    int y = p.second;
    for(int i = 0; i < 4; i++) {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(0 <= nx && nx < H && 0 <= ny && ny < W && dist[nx][ny] == 0 && m[nx][ny] == '.') {
        dist[nx][ny] = dist[x][y] + 1;
        que.push(make_pair(nx, ny));
      }
    }
  }

  int black;

  rep(i, H) {
    rep(j, W) {
      if(m[i][j] == '#') {
        black++;
      }
    }
  }
  

  if(dist[H-1][W-1] != 0) {
    int ans = H * W - dist[H-1][W-1] - black;
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	vector<int> c(3, 0);
	rep (i, 3) cin >> c[i];

	sort(ALL(c), greater<int>());
	
	int res = c[0] * 10 + c[1] + c[2];

	cout << res << endl;

	return 0;
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	long long ans=0, res, B, s=1, e, N;
	int A;
	cin>>A>>B>>N; e=N;
	while(s<=e) {
		long long m=(s+e)>>1;
		if(m*B-1>N) e=m-1;
		else s=m+1;
	}
	if(e==0) res=N;
	else res=e*B-1;
	ans=max({A*res/B-res/B*A,A*N/B-N/B*A,0LL});
	if(B-1<=N) ans=max(ans,A*(B-1)/B);
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<map>
#include<stdlib.h>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f
long long mod=1e9+7;
ll solve(int x)
{
    int i,j,k;
    ll sum=0;

    for(i=0; i<=x; i++)
    {
        for(j=0; i+j<=x; j++)
        {

        }
    }
}
ll f(ll a,ll b,ll c)
{
    ll ans=1;
    a=a%c;
    while(b)
    {
        if(b%2==1)
        {
            ans=(ans*a)%c;
        }
        a=(a*a)%c;
        b=b/2;
    }
    return ans;
}
long long gcd(long long x,long long y)
{
    if(x<y)
    {
        swap(x,y);
    }
    while(y)
    {
        long long a=x%y;
        x=y;
        y=a;
    }
    return x;
}
ll vis[1000005];
void unit()
{
    vis[1]=1;
    int i,j;
    for(i=2; i<=1000006; i++)
    {
        if(!vis[i])
        {
            for(j=1; i*j<=1000006; j++)
            {
                vis[i*j]=1;
            }
            for(j=i; j<=1000006; j=j*i)
            {
                vis[j]=i;
            }
        }
    }
}
ll a[10005];
ll b[10005];
ll c[10005];
ll d[10005];
ll e[10005];
ll dp[10005];
ll sum[10005];
ll fpow[1000006];
ll w(int l,int r,int k)
{
    ll ans=0;
    int i;
    sort(a+l,a+r);


    if(r-l<=k)
    {
        for(i=l; i<=r-1; i++)
        {
            ans+=a[i];
        }
    }
    else
    {

        for(i=r-k; i<=r-1; i++)
        {

            ans+=a[i];
        }

    }

    return ans;


}
bool cmp(ll a,ll b)
{
    return a>b;
}
char s[200005];
int main()
{
   scanf("%s",s);
   int i,j;
   int pos=-1;
   int len=strlen(s);
   for(i=0;i<len;i++)
   {
       if(s[i]=='C')
       {
           pos=i;
           break;
       }
       else
       {
           continue;
       }
   }
   int flag=0;
   for(j=pos+1;j<len;j++)
   {
       if(s[j]=='F')
       {
           flag=1;
           break;
       }
   }
   if(pos==-1)
   {
       printf("No\n");
   }
   else
   {
       if(flag==1)
       {
           printf("Yes\n");
       }
       else
       {
           printf("No\n");
       }
   }




    return 0;
}




Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
#define mp make_pair
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;
using Ki = vector<vector<int>>;
using Vi = vector<int>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n,m;
    cin>>n>>m;
    Ki G(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i,n){
        cout<<G[i].size()<<endl;
    }
    
}

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

#ifndef INF
#define INF 100000
#endif

int main(){
	int N, K;
	cin >> N >> K;
	int ret = INF;
	int tmp;
	int A[N];
	int min_i;
	for(int i = 0; i < N; i++){
		cin >> A[i];
		if(A[i] == 1){
			min_i = i;
		}
	}
	for(int i = 0; i < K; i++){
		tmp = 1 + ceil((min_i - i) * 1.0 / (K - 1)) + ceil((N - (min_i + K) + i) * 1.0 / (K - 1));
		if(tmp < ret){
			ret = tmp;
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        List<Integer> arrayList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            arrayList.add(Integer.parseInt(sc.next()));
        }
        int count = 0;
        while(arrayList.stream().allMatch(e -> e % 2 == 0)) {
            arrayList = arrayList.stream().map(e -> e / 2).collect(Collectors.toList());
            count++;
        }
        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 29268
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE
//ABS, task 09, 2020/04/11
//ms, tle
/*
*/

int main(void){
  int N;
  string S;
  int64_t r=0;
  int64_t g=0;
  int64_t b=0;
  int64_t ans;

  cin >>N;
  cin >>S;

  for(int i=0;i<N;i++){
    if(S.at(i)=='R') r++;
    if(S.at(i)=='G') g++;
    if(S.at(i)=='B') b++;
  }

  ans = r*g*b;
  //cout <<"r:" <<r <<" g:"<<g <<" b:" <<b <<endl;

/*
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      if(S.at(i) != S.at(j) && 2*j-i<N){
        if(S.at(i) != S.at(2*j-i)
         &&S.at(j) != S.at(2*j-i)) ans--;
      }
    }
  }
*/
  for(int i=0;i<N;i++) {
   for(int j=i+1;i+1<N;j++) {
     int k = 2*j - i;
     if (k >= N) break;
     if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
   }
 }


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

/*
rgbrgb
8
,,,,,,
,,
*/


Measured memory_bytes: 3632
n = int(input())
a = []
b = []
for i in range(n):
   ai,bi = [int(j) for j in input().split()]
   a.append(ai)
   b.append(bi)
a.sort()
b.sort()
if n == 1:
   ans = b[0] - a[0] + 1
elif n % 2 == 1:
   tg = (n+1) // 2
   ans = b[-tg] - a[tg-1] + 1
else:
   tg = n//2
   ans = b[-tg] + b[-tg-1] - a[tg-1] - a[tg] +1
print(ans)

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;

const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;

/*
  filippos
  Contest : AtCoder DP contest
  Task : A - Frog1
*/

int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n; cin >> n;
  vi v(n);
  for(int &i : v)
    cin >> i;
  v.push_back(v.back());

  vi dp(n + 1);
  for(int i = n-2; i >= 0; i--)
    dp[i] = min(dp[i+1] + abs(v[i] - v[i+1]), dp[i+2] + abs(v[i] - v[i+2]));

  cout << dp[0];
  
  return cout << endl, 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var list = Console.ReadLine().Split().Select(elem => long.Parse(elem)).ToArray();
            var A = list[0];
            var B = list[1];

            var answer = Lcm(A, B);
            Console.WriteLine(answer);
        }

        // 最小公倍数
        public static long Lcm(long a, long b)
        {
            return a * b / Gcd(a, b);
        }

        // ユークリッドの互除法 
        public static long Gcd(long a, long b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
}


Measured memory_bytes: 13268
S=[]
total=0
q=10
for i in range(5):
    a=int(input())
    S.append(a)
for i in range(5):
    if S[i]%10==0:
        total+=S[i]
    else:
        total+=(S[i]//10+1)*10
        q=min(q,S[i]%10)
print(total-(10-q))

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

int dp[3010][3010];
pair<int, int> p[3010][3010];

int main()
{
    string s, t; cin>>s>>t;
    int n=s.size(), m=t.size();

    for(int i=0; i<=n; ++i)
        for(int j=0; j<=m; ++j)
            p[i][j]={-1, -1};

    for(int i=0; i<n; ++i) {
        for(int j=0; j<m; ++j) {
            if (s[i]==t[j]) {
                dp[i+1][j+1]=dp[i][j]+1;
                p[i+1][j+1]={i, j};
            }
            else {
                if (dp[i+1][j]>dp[i][j+1]) {
                    dp[i+1][j+1]=dp[i+1][j];
                    p[i+1][j+1]=p[i+1][j];
                }
                else {
                    dp[i+1][j+1]=dp[i][j+1];
                    p[i+1][j+1]=p[i][j+1];
                }
            }
        }
    }
    string res;
    int i, j; tie(i, j)=p[n][m];
    while (i>=0) {
        res+=s[i];
        tie(i, j)=p[i][j];
    }
    reverse(begin(res), end(res));
    cout<<res<<endl;
}


Measured memory_bytes: 106368
#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 ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  cout << ( abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d ) ? "Yes" : "No" ) << endl;
}



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

long long MOD = 1000000007;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	long long ANS = (Calc(2, N) + MOD - 1) % MOD;
	long long P = 1, Q = 1, R = 1, S = 1;
	for (long long i = N - A + 1; i <= N; i++) P *= i, P %= MOD;
	for (long long i = 1; i <= A; i++) Q *= i, Q %= MOD;
	for (long long i = N - B + 1; i <= N; i++) R *= i, R %= MOD;
	for (long long i = 1; i <= B; i++) S *= i, S %= MOD;
	ANS += MOD - (P * Calc(Q, MOD - 2)) % MOD;
	ANS %= MOD;
	ANS += MOD - (R * Calc(S, MOD - 2)) % MOD;
	ANS %= MOD;
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main()
{
    int N;
    std::cin>>N;
    int A[25];
    int B[25];
    int C[25];
    for(int i=1;i<=N;i++)std::cin>>A[i];
    for(int i=1;i<=N;i++)std::cin>>B[i];
    for(int i=1;i<=N-1;i++)std::cin>>C[i];
    int count = B[A[1]];
    int past = A[1];
    for(int i=2;i<=N;i++){
        count += B[A[i]];
        if(A[i]-past==1)count += C[past];
        past = A[i];
    }
    std::cout<<count<<std::endl;
}    

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

typedef ostringstream OSS;
typedef istringstream ISS;

typedef long long LL;
typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<string> VS;
typedef vector<VS> VVS;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<PII> VPII;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x) (x).begin(),(x).end()
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N) for (int i = (init); i < (int)(N); i++)

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a) { OSS oss; oss << a; return oss.str(); };

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const double EPS = 1e-12;

struct Tile {
    int type;
    PII another;
};

int N;
map<PII, Tile> ts;

bool solve() {
    // p, set_type
    stack<pair<PII, int>> q;

    for (auto t : ts) {
        q.push(MP(t.fst, 0));
    }

    while (q.size()) {
        PII p = q.top().fst;
        int type = q.top().snd;
        Tile &t = ts[p];
        q.pop();

        if (t.type != 0) { // done
            if (type != 0 && t.type != type) {
                return false;
            }
            continue;
        }

        if (type == 0) { // init
            type = 1;
        }

        t.type = type;

        q.push(MP(t.another, type == 1 ? 2 : 1));

        REP(i, 0, 4) {
            PII np(p.fst + DY[i], p.snd + DX[i]);

            if (np != t.another && ts.count(np)) {
                q.push(MP(np, type));
            }
        }
    }

    return true;
}

int main(void) {
    while (cin >> N, N) {
        ts.clear();
        REP(i, 0, N) {
            int x, y;
            char dir;
            cin >> x >> y >> dir;

            PII p1(y, x);
            PII p2(y + (dir == 'y'), x + (dir == 'x'));

            Tile t1;
            Tile t2;

            t1.another = p2;
            t2.another = p1;

            t1.type = t2.type = 0;

            ts[p1] = t1;
            ts[p2] = t2;
        }

        cout << (solve() ? "Yes" : "No") << endl;
    }

	return 0;
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	ll n,k;cin>>n>>k;

	ll ans=0;
	for(ll i=k;i<=n+1;i++){//何個選ぶか
		ll l=i*(i-1)/2,r=i*(2*n-i+1)/2;
		//ll l=0,r=0;
		//for(int i=0;i<k;i++) l+=i;
		//for(int i=n;i>n-k;i--) r+=i;
		//cout<<l<<" "<<r<<"\n";
		ans=(ans+(r-l+1)%MOD)%MOD;
	}
	cout<<ans<<endl;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int a, b; cin >> a >> b;
    if(1 <= a && a <= 9 && 1 <= b && b <= 9){
        cout << a * b << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3540
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))
pi = 0
qi = 0
for i, item in enumerate(itertools.permutations(list(range(1,n+1)))):
    if item == p:
        pi = i
    if item == q:
        qi = i
print(abs(pi- qi))


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

int main() {
  string s = "aiueo";
  char c;
  cin >> c;
  int a = 0;

  for (int i = 0; i < 5; i++) {
    if (c == s.at(i))
      a = 1;
  }
  
  if (a == 1)
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int x = sc.nextInt();
    int a[] = new int[N];
    long total = 0;
    int count = 0;
    for(int i=0; i<N; i++) {
      a[i] = sc.nextInt();
      total += a[i];
    }
    Arrays.sort(a);
    if(x==total) {
      System.out.println(N);
    } else if(x>total) {
      System.out.println(N-1);
    } else {
      for(int j=0; j<N; j++){
        if(x>=a[j]){
          x -= a[j];
          count++;
        } else {
          break;
        }
      }
      System.out.println(count);
    }    
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int k,s;
  cin>>k>>s;
  long long ans=0;
  REP(x,k+1){
    REP(y,k+1){
      if(0<=s-x-y && s-x-y<=k){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define mp make_pair
#define pb push_back
priority_queue<pll,vector<pll>,greater<pll> >pq;
#define ll long long


int main(){
    int n;
    cin>>n;
    vector<ll>a(n+1),b(n+1),c(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<vector<ll> >dp(n+1,vector<ll>(4,0));
    for(int i=1;i<=n;i++){
            //cout<<"sgfd";
        dp[i][1]=a[i]+max(dp[i-1][2],dp[i-1][3]);
        dp[i][2]=b[i]+max(dp[i-1][1],dp[i-1][3]);
        dp[i][3]=c[i]+max(dp[i-1][2],dp[i-1][1]);
    }
    cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));
    return 0;
}


Measured memory_bytes: 9600
import sys
sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():


    H, N = map(int, input().split())
    A, B = [0] * N, [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    INF = 10**10  # INF+INFを計算してもオーバーフローしない範囲で大きく

    I, J = N, H
    # dpテーブル dp[i][j]:=i番目以下でjのダメージを与えるための最小コスト
    dp = [[INF]*(J+1) for _ in range(I+1)]
    # 初期条件
    for i in range(I):
        dp[i][0] = 0
    # ループ
    for i in range(I):
        for j in range(J+1):
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            dp[i+1][min(j+A[i],J)] = min(dp[i+1][min(j+A[i],J)], dp[i+1][j]+B[i])
            
            
    print(dp[I][J])


resolve()

Measured memory_bytes: 119664
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] arr = new int[N];
        boolean flg = true;
        int count = 0;

        for(int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        while(flg) {
            boolean existOdd = false;
            for(int i = 0; i < N; i++) {
                if(arr[i] % 2 != 0){
                    flg = false;
                }
            }
            if(!flg) break;

            for(int j = 0; j < N; j++) {
                arr[j] = arr[j] / 2;
            }
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21844
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = map(int, input().split())

    for a in A:
        if not a % 2:
            if not a % 3 or not a % 5:
                continue
            else:
                print('DENIED')
                break
    else:
        print('APPROVED')


main()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;

int main() {
	string S;
	cin >> S;
	string T;
	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j <= S.size() - i; j++) {
			T = S.substr(i, j);
			bool ok = true;
			for (char c : T) {
				if (c != 'A' && c != 'C' && c != 'G' && c != 'T') ok = false;
			}
			if (ok) ans = max(ans, (int)T.size());
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	string s1;
  	cin>>s1;
  	string s2;
  	cin>>s2;
  	int k=0;
  	for(int i=0;i<3;i++)
    {
    	if(s1[i]==s2[i])
        {
          k++;
        }
    }
  	cout<<k;
  	return 0;
}

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

using namespace std;

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	int n, m;

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

	int sum = 0;

	for (int i = 0; i < m; i++){
		int a;
		scanf("%d", &a);
		sum += a;
	}

	if (sum > n){
		printf("-1\n");
	} else {
		printf("%d\n", n - sum);
	}

	return 0;
}

Measured memory_bytes: 3720
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
a.sort!

plusc = a.count{|e| e > 0}
minusc = a.count{|e| e < 0}
has_zero = a.any?{|e| e == 0}

if plusc == 0 && k.odd?
  if has_zero
    puts 0
  else
    ans = 1
    k.times do |i|
      ans = ans * a[-i-1] % MOD
      # ans = ans % MOD if i.even?
    end
    ans = (ans + MOD) % MOD
    puts ans
  end
  exit
end
# -------


ans = 1
l = 0
r = n - 1

if k.even?
  while l + (n-1-r) + 2 <= k
    lmul = a[l] * a[l+1]
    rmul = a[r-1] * a[r]
    if lmul > rmul || (plusc <= 2 && k.odd?)
      ans = ans * lmul % MOD
      l += 2
      minusc -= 2
    else
      ans = ans * rmul % MOD
      r -= 2
      plusc -= 2
    end
    # p [[l, r], [lmul, rmul], ans]
  end

else
  while l + (n-1-r) + 2 <= k
    lmul = a[l] * a[l+1]
    rmul = a[r-1] * a[r]
    if lmul * a[r] > rmul * a[r-2] || (plusc <= 2 && k.odd?)
      ans = ans * lmul % MOD
      l += 2
      minusc -= 2
    else
      ans = ans * rmul % MOD
      r -= 2
      plusc -= 2
    end
    # p [[l, r], [lmul, rmul], ans]
  end
end


if l + (n-1-r) < k
  ans = [ans * a[l], ans * a[r]].max
end

ans = (ans + MOD) % MOD
puts ans


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

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S =="Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;
#define upd_min(miner, updater) if (miner > updater) miner = updater;

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

void ansYES(bool flag){
    if (flag) cout << "YES" << endl; else  cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

int nanko(string s,Int n,Int i){
    Int length = min(n - i - 1,i);
    Int ans = 0;
    for (int k = i-length;k < i;k++){
        if (s.at(k) == 'R' && s.at(i +  (i - k) == 'B')) ans++;
    }
    return ans;
}


int main() {
    long double d;
    cin >> d;
    cout << setprecision(15) << (2 * d * M_PI) << endl;
}

Measured memory_bytes: 3788
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String[] n = saori.nextHayami().split("");
		if(n[0].equals(n[2])){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		int N = Integer.parseInt(stdin.next());
		int k= Integer.parseInt(stdin.next());
		int K[] = new int[N];

		int Q = stdin.nextInt();
		int A[] = new int[Q];
		for(int i=0;i<Q;i++) {
			A[i] = Integer.parseInt(stdin.next());
		}
		for(int i=0;i<N;i++) {
			K[i] = k-Q;
		}
		
		for(int i=0;i<Q;i++) {
			K[A[i]-1] += 1;
		}
		
		for(int i=0;i<N;i++) {
			if(K[i] <=0) {
				out.println("No");
			}
			else {
				out.println("Yes");
			}
		}
		out.flush();
	}
	
}

Measured memory_bytes: 48828
n = int(input())
a = list(map(int, input().split()))
s = set()

index2 = 0
for i in range(n+1):
    if a[i] in s:
        index2 = i
    s.add(a[i])

index1 = 0
for i in range(n+1):
    if a[i] == a[index2]:
        index1 = i
        break

#combination---
m = 10**9 + 7
fac = [1, 1]
inv = [1, 1]
finv = [1, 1]
for i in range(2, n+5):
    fac.append(fac[i-1] * i % m)
    inv.append(m - inv[m%i] * (m//i) % m)
    finv.append(finv[i-1] * inv[i] % m)

def nck(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % m) % m

#-----


for k in range(1, n+2):
    print((nck(n + 1, k) - nck(index1 + n - index2, k-1)) % m)


Measured memory_bytes: 25784
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s; cin >> s;
  int sum = 0;
  for(int i = 0; i < s.size(); i++){
    char a = s.at(i);
    int b = a - '0';
    sum += b;
   // cout << sum << endl;
  }
  //cout << sum << endl;
  if(sum % 9 == 0 or sum == 0)
    cout << "Yes";
  else
    cout << "No";
}

Measured memory_bytes: 3748
package main

import "fmt"

const c = 1000000007

func fact(n int64) int64 {
	if n == 1 {
		return 1
	}
	return n * fact(n-1) % c
}

func solve(n, m int64) int64 {
	switch n {
	case m:
		return fact(n) * fact(m) * 2 % c
	case m + 1, m - 1:
		return fact(n) * fact(m) % c
	}
	return 0
}

func main() {
	var n, m int64
	fmt.Scan(&n, &m)
	fmt.Println(solve(n, m))
}


Measured memory_bytes: 7040
# ABC 121 C

N, M = map(int, input().split())

arr = []

for i in range(N):
    arr.append(list(map(int, input().split())))

arr.sort()

sum = 0

for i in range(N):
    if arr[i][1] < M:
        sum += arr[i][0] * arr[i][1]
        M -= arr[i][1]
    else:
        sum += arr[i][0] * M
        break

print(sum)


Measured memory_bytes: 27756
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> sticks(N);
    for(int i = 0; i < N; i++) cin >> sticks[i];

    sort(sticks.begin(), sticks.end(), greater<int>());

    int max_snake_length = 0;
    for(int i = 0; i < K; i++) max_snake_length += sticks[i];

    cout << max_snake_length << endl;

    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#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 ll long long 
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
  ll a,b,c,k;
  cin >>a>>b>>c>>k;
  if(k<=a){
    cout <<k <<endl;
    return 0;
  }
  if(k<a+b){
    cout <<a<<endl;
    return 0;
  }
  cout <<a-k+a+b<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
using ll = long long;
using P = pair<int,int>;

int main(void) {
  int D;
  cin >> D;

  if(D==25) {
    cout << "Christmas" << endl;
  } else if(D==24) {
    cout << "Christmas Eve" << endl;
  } else if(D==23) {
    cout << "Christmas Eve Eve" << endl;
  } else if(D==22){
    cout << "Christmas Eve Eve Eve" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

import sys

def solve(n, s, j, a, c):
    if len(a) == n:
        if sum(a) == s:
            c += 1
    elif len(a) < n:
        for i in range(j, 10):
            c = solve(n, s, i+1, a + [i], c)
    return c

for line in sys.stdin:
    if line == "0 0\n":
        break
    else:
        nums = line.replace('\n', '').split(' ')
        n = int(nums[0])
        s = int(nums[1])
        c = solve(n, s, 0, [], 0)
        print c

Measured memory_bytes: 4228
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <list>
#include <utility>
using namespace std;
#define MS0(I) memset(I, 0, sizeof(I));
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, s, n) for(int i = (s); i < (n); ++i)
#define MAX 100000
typedef long long LL;
typedef unsigned long long ULL;
typedef struct u{
    int s,t,c;
}u;
u record[MAX];
int cmp(const void*v1, const void*v2){
    return ((u*)v1)->s - ((u*)v2)->s;
}
bool check[MAX];
int main(void){	
    int n, c; scanf("%d%d", &n, &c);
    rep(i, n) scanf("%d %d %d", &record[i].s, &record[i].t, &record[i].c);
    qsort(record, n, sizeof(u), cmp);
    int left = n;
    int ret = 0;
    while(left){
        ret++;
        int t = 0, k = -1;
        rep(i, n){
            if(check[i]) continue;
            if(record[i].c == k && t <= record[i].s){
                t = record[i].t;
                check[i] = 1;
                left--;
            }
            else if(record[i].c != k && t <= record[i].s - 1){
                t = record[i].t; 
                k = record[i].c;
                check[i] = 1;
                left--;
            }
        }
    }
    printf("%d", ret);
    return 0;
}


Measured memory_bytes: 2556
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
int main() {
  int N;
  cin>>N;
  vector<int64_t>T(N);
  for(int i=0;i<N;i++){
    cin>>T[i];
  }
  int64_t m=1;
  for(int i=0;i<N;i++){
    m=m/__gcd(m,T[i])*T[i];
  }
  cout<<m<<endl;
  return 0;
}

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

int main(void){
    string s = "";char c[3];
    cin >> c[0] >> c[1] >> c[2];
    sort(c,c+3);
    s = c[0];
    s += c[1];
    s += c[2];
    if(s == "abc")cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

    int N;
    cin >> N;
    vector<int> p(N);
    for (auto &x : p) cin >> x;

    int ans = 0;
    for (int i = 0; i < N - 1; ++i) {
        if (p.at(i) == i + 1) {
            swap(p.at(i), p.at(i + 1));
            ans++;
        }
    }
    if (p.back() == N) ans++;

    cout << ans << endl;

    return 0;
}

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

int main() {
	int N, j = 0, l = 0, k= 0, f = 0;
	cin >> N;
	
	rep(i, N) {
		char S;
		cin >> S;
		if (S == 'P') {
			l = 1;
		}if (S == 'W') {
			j = 1;
		}if (S == 'G') {
			k = 1;
		}if (S == 'Y') {
			f = 1;
		}
	}
	if (l+j+k+f == 4) {
		cout << "Four" << endl;
		}if (l + j + k + f == 3) {
			cout << "Three" << endl;
		}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long


int main() {
    LL n, m;
    cin >> n >> m;

    vector<pair<LL, LL>> v;
    for (LL i=0; i < m; i++) {
        LL a, b;
        cin >> a >> b;
        v.push_back(make_pair(a - 1, b - 1));
    }

    LL island[100000];
    LL member[100000];
    for (LL i=0; i < n ;i++) {
        island[i] = i;
        member[i] = 1;
    }

    vector<LL> ans;
    ans.push_back((n * (n - 1) / 2));

    LL inconv = (n * (n - 1) / 2);
    for (LL i = m - 1; i > 0; i--) {
        pair<LL, LL> p = v.back();
        v.pop_back();
        LL a = p.first, b = p.second;

        while(island[a] != a) {
            a = island[a];
        }
        island[p.first] = a;

        while(island[b] != b) {
            b = island[b];
        }
        island[p.second] = b;

        // for (LL i=0; i < n;i ++) {
        //     cout << island[i] << ", ";
        // }
        // cout << endl;
        // for (LL i=0; i < n;i ++) {
        //     cout << member[i] << ", ";
        // }
        // cout << endl << endl;

        if (a < b) {
            LL t = member[b];
            inconv += (t * (t - 1) / 2);
            t = member[a];
            inconv += (t * (t - 1) / 2);
            island[b] = a;
            member[a] += member[b];
            t = member[a];
            inconv -= (t * (t - 1) / 2);
            member[b] = 0;

        } else if (a > b){
            LL t = member[a];
            inconv += (t * (t - 1) / 2);
            t = member[b];
            inconv += (t * (t - 1) / 2);
            island[a] = b;
            member[b] += member[a];
            t = member[b];
            inconv -= (t * (t - 1) / 2);
            member[a] = 0;
        } else {

        }


        // for (LL j=0; j < n; j++) {
        //     LL t = member[j];
        //     inconv -= (t * (t - 1) / 2);
        // }

        // if (inconv == 0) {
        //     for (LL j=0; j < m - i + 2;j++) {
        //         ans.push_back(0);
        //     }
        //     break;
        // }

        ans.push_back(inconv);
    }

    for (LL i = m - 1; i >= 0; i--) {
        cout << ans[i] << endl;
    }


    return 0;
}


Measured memory_bytes: 6256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import time
import math
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
sys.setrecursionlimit(10**7)
input=lambda :sys.stdin.readline().rstrip()
N,M=map(int,input().split())
A=list(map(int,input().split()))
print(N-sum(A) if N-sum(A)>=0 else -1)


Measured memory_bytes: 72936
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); ++i)
const int INF = 1 << 30;
using namespace std;

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

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

  int n; cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  // その地点での最適コスト
  int dp[100010] = {};
  rep(i, 100010) dp[i] = INF;
  dp[0] = 0;
  rep(i, n) {
    chmin(dp[i+1], dp[i] + abs(h[i]-h[i+1]));
    chmin(dp[i+2], dp[i] + abs(h[i]-h[i+2]));
  }

  cout << dp[n-1] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int N,A,B;
  //Neabcd
  cin >> N >> A >> B;
  
  int sum = 0;
  for(int i=1; i<=N; i++){
    int a,b,c,d,e;
    d=i%10;
    c=((i-d)%100)/10;
    b=((i-d-c*10)%1000)/100;
    a=i/1000%10;
    e=i/10000;
    if(A <= a+b+c+d+e && a+b+c+d+e <= B){
      sum += i;
    }
  }
  
  cout << sum << endl;
}

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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+3;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ll p=MOD;a%=p;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=p;--b;}a*=a;a%=p;b/=2;}return pr;}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<=N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<=N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///



void _case()
{
    ll n,i,k=0,x=0;
    string a;
    cin>>a;
    for(i=0;i<3;i++){
        if(a[i]=='R') x++,k=max(x,k);
        else x=0;
    }
    cout<<k el;
}

main()
{
      fastio();
        _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3648