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

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple

#define N 311111
#define A 1111111
#define BLOCK 555 // ~sqrt(N)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

const int INF = 1e9 +5;
const int nax = 1e5 +5;

int dp[nax];
int visited[nax];
int in_degree[nax];
vector<int> edges[nax];

void dfs(int a){
	visited[a]=true;
	for(int b : edges[a]){
		in_degree[b]--;
		dp[b] = max(dp[b], dp[a]+1);
		if(in_degree[b]==0){
			dfs(b);
		}
	}
}

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

	int t;
	// cin>>t;
	t = 1;
	while(t--){
		int n,m;
		int ans = 0;
		cin>>n>>m;
		for(int i=0;i<m;i++){
			int x,y;
			cin>>x>>y;
			edges[x].PB(y);
			in_degree[y]++;
		}

		for(int i=1;i<=n;i++){
			if(in_degree[i]==0 && !visited[i]){
				dfs(i);
			}
		}
		for(int i=1;i<=n;i++){
			ans = max(ans,dp[i]);
		}

		cout<<ans<<endl;
	}
}



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

typedef long long ll;

#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(a) a.begin(), a.end()

const int maxn = 200010;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;
int n, m, a[maxn*5];
bool prime[maxn*5];
string s, ss;

vector<int> generate_prime(int n)
{
    vector<int> v;
    map<int, int> M;
    v.clear(), M.clear();
    while(n%2==0) M[2]=1, n/=2;
    for(int i = 3; i*i < n; i+=2)
        while(n%i==0) n/=i, M[i]=1;
    if(n>2) v.push_back(n);
    for(auto u : M) v.push_back(u.first);
    return v;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    int gcd = a[0];
    for(int i = 1; i < n; i++) gcd = __gcd(gcd, a[i]);
    bool ok=true;
    map<int, int> M;
    for(int i = 0; i < n; i++)
    {
        vector<int> v;
        v = generate_prime(a[i]);
        for(auto u : v)M[u]++;
        v.clear();
    }
    for(auto u : M) if(u.second>1) ok=false;
    if(ok) cout << "pairwise coprime\n";
    else if(gcd==1) cout << "setwise coprime\n";
    else cout << "not coprime\n";
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a;
  int t = n, sum = 0;
  for (int i = 1; t > 0; i ++) {
    a.push_back(i);
    t -= i;
    sum += i;
  }

  for (int i = 0; i < a.size(); i ++) {
    if (a[i] == sum - n) continue;
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 384
<?php
  declare(strict_types=1);

  fscanf(STDIN, "%i %i", $n, $m);
  $g = (int)0;
  for ($i = 0; $i < $m; ++$i)
  {
      fscanf(STDIN, "%i %i", $a, $b);
      $g |= 1 << (($a - 1) * $n + $b - 1);
      $g |= 1 << (($b - 1) * $n + $a - 1);
  }

  $limit = (int)1 << $n;
  for ($passing = (int)1; $passing < $limit; $passing += 2)
  {
      for ($i = 0; $i < $n; ++$i)
      {
          $dp[$passing][$i] = (int)0;
      }
  }  
  for ($i = 0; $i < $n; ++$i)
  {
      $dp[1 << $i][$i] = (int)1; // trivial paths
  }
  for ($passing = (int)1; $passing < $limit; $passing += 2)
  {
      for ($i = 0; $i < $n; ++$i)
      {
          if ($dp[$passing][$i] <= 0 || ($passing & (1 << $i)) === 0)
          {
              continue;
          }

          $unexplored = ~$passing & ($g >> ($i * $n));
          for ($j = 0; $j < $n; ++$j)
          {
              $dp[$passing | (1 << $j)][$j] += (($unexplored >> $j) & 1) * $dp[$passing][$i];
          }
      }
  }
  
  echo array_sum($dp[$limit - 1]).PHP_EOL;


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
char ans[100][100];

int main(){
	int a, b; cin >> a >> b; a--; b--;
    rep(i,100) rep(j,100) { if(i<50) ans[i][j] = '.'; else ans[i][j] = '#'; }
    rep(i,b/50) rep(j,50) ans[i*2][j*2] = '#';
    rep(j,b%50) ans[b/50*2][j*2] = '#';
    rep(i,a/50) rep(j,50) ans[i*2+51][j*2] = '.';
    rep(j,a%50) ans[a/50*2+51][j*2] = '.';
    cout << 100 << " " << 100 << endl;
    rep(i,100) { rep(j,100) cout << ans[i][j]; cout << endl; }
}

Measured memory_bytes: 3648
from bisect import bisect_left as bl

while True:
  n, m = map(int, input().split())
  if n == 0:
    break
  klst = list(map(int, input().split()))
  cum = []
  acc = 0
  for k in klst:
    acc += k
    acc %= m
    cum.append(acc)
  
  use = [0]
  use_len = 1
  ans = 0
  for k in cum:
    ind = bl(use, k + 1)
    if ind < use_len:
      ans = max(ans, (k - use[ind]) % m)
    ans = max(ans, k)
    use.insert(bl(use, k), k)
    use_len += 1
  print(ans)


Measured memory_bytes: 10888
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i <n;i++)
int main(){
    string s,t;cin >> s >>t;
    if(s.size() < t.size()) return 0;
    rep(i,s.size() - t.size()+1){
        rep(j,t.size()){
            if(s[i+j] != t[j]) break;
            if(j==t.size()-1){
                cout << i<<endl;
            }
        }
    }
}


Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {

	static long gcd(long a, long b){

		if(b==0)
			return a;
		else
			return gcd(b,a%b);
	}
	
	static int calc(int a, int x, int m){
		return a*x%m;
	}

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

		while(true){			
			int a[] = new int[3];
			int m[] = new int[3];
			int cnt[] = new int[3];
			int x;
			int flag=0;
			
			for(int i=0;i<3;i++){
				a[i]=stdIn.nextInt();
				m[i]=stdIn.nextInt();
				if(a[i]==0&&m[i]==0){
					flag++;
				}
			}
			
			if(flag==3){
				break;
			}
			
			for(int i=0;i<3;i++){
				x=1;
				while(true){
					x=calc(a[i],x,m[i]);
					cnt[i]++;
					if(x==1){
						break;
					}
				}
			}
			
			long gcd1 = gcd(cnt[0],cnt[1]);
			long gcd2 = gcd(cnt[0],cnt[2]);
			
			long lcm1 = cnt[0]*cnt[1]/gcd1;
			long lcm2 = cnt[0]*cnt[2]/gcd2;
			
			long gcd_ans = gcd(lcm1,lcm2);
			long lcm_ans = lcm1*lcm2/gcd_ans;
			
			System.out.println(lcm_ans);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a=0,b=0;
  	cin >> a >> b;
  	
  	if (a<=b){
   		while(b > 0){
            cout << a;
        	b--;
        }
    }else if (a>b){
   		while(a > 0){
            cout << b;
        	a--;
        }
    }
}

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

int main() {
  vector<int> vec(3);
  rep(i,0,3) cin >>vec[i];
  sort(vec.begin(),vec.end());
  int ans=0;
  rep(i,0,2) ans+=vec[i+1]-vec[i];
  cout <<ans <<endl;
  return 0;
}


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

int N, M, A[100009], B[100009], col[100009], z[2]; vector<int>x[100009]; bool OK = false;

void dfs(int pos, int depth) {
	if (col[pos] >= 0) {
		if (col[pos] != depth) OK = true;
		return;
	}
	col[pos] = depth; z[depth]++;
	for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i], depth ^ 1);
}

int main() {
	cin >> N >> M;
	for (int i = 1; i <= M; i++) {
		cin >> A[i] >> B[i];
		x[A[i]].push_back(B[i]);
		x[B[i]].push_back(A[i]);
	}
	for (int i = 1; i <= N; i++) col[i] = -1;
	dfs(1, 0);
	long long G1 = 1LL * z[0] * z[1];
	if (OK == true) G1 = 1LL * N*(N - 1) / 2LL;
	cout << G1 - M << endl;
	return 0;
}

Measured memory_bytes: 7680
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val s = sc.next()
    if (s.length != 3) {
        println("No")
        return
    }
    if (s.contains("A") && s.contains("B"))
        println("Yes")
    else
        println("No")
}

Measured memory_bytes: 29360
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include  <utility>
#define MAX 1001
using namespace std;

int main()
{
    int n;
    vector<int> arr(MAX);
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
    }

//    vector<int>::iterator itr = arr.begin();
//    swap(itr )

    int q, b, e, t;
    scanf("%d", &q);
    for (int i = 0; i < q; i++)
    {
        scanf("%d %d %d", &b, &e, &t);
        vector<int>::iterator itr = arr.begin();
        for (int k = 0; k < e - b; k++)
        {
            swap(*(itr + b + k), *(itr + t + k));
        }
    }

    printf("%d", arr[0]);
    for (int i = 1; i < n; i++)
    {
        printf(" %d", arr[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

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


int h, w, c;

int dfs(int x, int y, vector<vector<int>>& used, const vector<vector<int>>& b) {
	used[x][y] = 1;
	int res = 1;
	for (int i = 0; i < 4; i++) {
		int tx = x + dx[i], ty = y + dy[i];
		if (0 <= tx && tx < h && 0 <= ty && ty < w && used[tx][ty] == 0 && b[tx][ty] == c) {
			res += dfs(tx, ty, used, b);
		}
	}
	return res;
}

int main()
{
	while (cin >> h >> w >> c, h | w | c) {
		c--;
		vector<vector<int>> col(h, vector<int>(w));
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> col[i][j]; col[i][j]--;
			}
		}
		int res = 0;
		for (int i = 0; i < 6 * 6 * 6 * 6 * 6; i++) {
			int t = i;
			auto b = col;
			for (int j = 0; j < 5; j++, t /= 6) {
				int to = t % 6;
				int lu = b[0][0];
				if (to == lu) continue;
				queue<pii> q;
				q.emplace(0, 0);
				b[0][0] = to;
				while (!q.empty()) {
					auto p = q.front(); q.pop();
					for (int i = 0; i < 4; i++) {
						int tx = p.first + dx[i], ty = p.second + dy[i];
						if (0 <= tx && tx < h && 0 <= ty && ty < w && b[tx][ty] == lu) {
							q.emplace(tx, ty);
							b[tx][ty] = to;
						}
					}
				}
			}
			if (b[0][0] == c) {
				vector<vector<int>> used(h, vector<int>(w));
				res = max(res, dfs(0, 0, used, b));
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3052
#include <iostream>

#include <string>
#include <vector>

#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::vector;

using std::sort;

static string
solve(int N, vector<int> &A)
{
  sort(A.begin(), A.end());
  for (int n = 1; n < N; n++)
  {
    if (A[n - 1] == A[n])
    {
      return "NO";
    }
  }
  return "YES";
}

int
main()
{
  int N;
  cin >> N;
  vector<int> A(N);
  for (int n = 0; n < N; n++)
  {
    cin >> A[n];
  }
  cout << solve(N, A) << endl;
  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 all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main(){
  int h, w;
  cin >> h >> w;
  bool odd = false;
  int y, x;
  vector<vector<int>> mat(h, vector<int>(w));
  rep(i, h){
    rep(j, w){
      cin >> mat[i][j];
    }
  }
  vector<string> vec;
  int cnt = 0;
  rep(i, h){
    if(i%2 == 0){
      rep(j, w){
        int num = mat[i][j];
        if(!odd){
          if(num % 2 == 1){
            odd = true;
            y = i+1; x = j+1;
          }
        }else{
          vec.push_back(to_string(y)+" "+to_string(x)+" "+to_string(i+1)+" "+to_string(j+1));
          y = i+1; x = j+1;
          cnt++;
          if(num % 2 == 1){
            odd = false;
          }
        }
      }
    }else{
      for(int j=w-1; j>=0; j--){
        int num = mat[i][j];
        if(!odd){
          if(num % 2 == 1){
            odd = true;
            y = i+1; x = j+1;
          }
        }else{
          vec.push_back(to_string(y)+" "+to_string(x)+" "+to_string(i+1)+" "+to_string(j+1));
          y = i+1; x = j+1;
          cnt++;
          if(num % 2 == 1){
            odd = false;
          }
        }
      }
    }
  }
  cout << cnt << endl;
  rep(i, vec.size()) cout << vec[i] << endl;
  return 0;
}
  
        
        
        
        

Measured memory_bytes: 8468
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String str=s.next();
		int x=0;
		for (int i = 0; i < str.length(); i++) {
			if(i%2==0){
				if(str.charAt(i)=='R' || (str.charAt(i)=='U' || str.charAt(i)=='D')) {
					continue;
				}
				else {
					x=-1;
					break;
				}
			}
			else {
				if(str.charAt(i)=='L'|| (str.charAt(i)=='U' || str.charAt(i)=='D')) {
					continue;
				}
				else {
					x=-1;
					break;
				}
			}
		}
		if(x==-1) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
	}

}


Measured memory_bytes: 21972
#include<stdio.h>
 
int main(void) {
 
	int x;
	int a, b, c, d, e, f;
	int tmp;  
	
	scanf("%d", &x);
 
	for (a = 0; a <= (x/100); a++) {
		for (b = 0; b <= (x/101); b++) {
			for (c = 0; c <= (x / 102); c++) {
				for (d = 0; d <= (x / 103); d++) {
					for (e = 0; e <= (x / 104); e++) {
						for (f = 0; f <= (x / 105); f++) {
							tmp = 100*a + 101*b + 102*c + 103*d + 104*e + 105*f;
							if (tmp == x) {
								
								printf("1\n");
								return 0;
							}
						}
					}
				}
			}
		}
	}
	
	printf("0\n");
 
	return 0;
}

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

void ioinit() { ios::sync_with_stdio(0); cin.tie(0); }

int main() {
  ioinit();
  int a, b, c;
  cin >> a >> b >> c;
  string ret = "No";
  if ((a-c)*(b-c) < 0) ret = "Yes";
  cout << ret << endl;  
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int H, W, h, w;
  cin >> H >> W >> h >> w;

  int ans = H * W - (H * w + W * h) + h * w;
  cout << ans << endl;
  return 0;
}


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

int main() {
  int n,k;
  cin>>n>>k;
  int ans=0;
  for (int i=0; i<n; i++) {
    int h;
    cin>>h;
    if (h>=k) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
result = [0] * N
route = [0] * N

for _ in range(M):
    A, B = map(int, input().split())
    route[A-1] = 1
    route[B-1] = 1
    if H[A-1] > H[B-1]:
        if result[A-1] != -1:
            result[A-1] = 1
        result[B-1] = -1
    elif H[A-1] < H[B-1]:
        result[A-1] = -1
        if result[B-1] != -1:
            result[B-1] = 1
    else:
        result[A-1] = -1
        result[B-1] = -1

print(result.count(1) + route.count(0))


Measured memory_bytes: 19896
#import<bits/stdc++.h>
using namespace std;set<int>A;long K,S,T,U,c[51]={1},P[51],a,w;main(){for(cin>>K>>K>>S>>T;cin>>U;)for(~U&S|U&~T||(A.insert(U),0),++w,U=K;U;U--)P[w]+=c[U]+=c[U-1];for(;U<1<<18;U++){map<int,int>M;w=0;for(int v:A)w-=P[M[v&=U]]-P[++M[v]];a+=~U&S|U&~T?0:__builtin_parity(U-S)?-w:w;}cout<<a;}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
#define zeroes(x) memset(x,0,sizeof(x))
typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn=100000;


int main()
{	
    IOS
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
       vl dp(n+1,mod);
    dp[0]=0;

    for(ll i=0;i<n;i++)
    {
       
        for(ll j=1;j<=k;j++)
        {
            if(i+j<n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
            }
        }
    }
    cout<<dp[n-1];
  


}


Measured memory_bytes: 1792
sub f{my($x,$b,$w)=($_,1,1);$_-"@_"and($w*=f($x))%=$==1e9+7,$b=$b*$c%$=for@$x;($b+($c=$w))%$=}$_+=<>;map{push@$_,$_[--$|]for@_=glob}<>;print f

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

int main()
{
  string S;
  cin>>S;
  int ans=0;
  if(S[0]==S[1])ans+=1;
  if(S[0]==S[2])ans+=1;
  if(S[0]==S[3])ans+=1;
  if(S[1]==S[2])ans+=1;
  if(S[1]==S[3])ans+=1;
  if(S[2]==S[3])ans+=1;
  if(ans==2) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main()
{
	int a, b, c;
	int k;
	int n;

	scanf("%d%d%d", &a, &b, &c);
	n = 0;
	for (k = a; k <= b; k++) {
		if (c % k == 0) n++;
	}
	printf("%d\n", n);
	return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main() {
    int n, r;
    cin >> n >> r;
    if (n >= 10) {
        cout << r << endl;
    }
    else {
        cout << r + 100 * (10 - n) << endl;
    }
}


Measured memory_bytes: 3596
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) (v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;
const int maxn = 2000100;



int main(){
        _
        ll a, b; cin >> a >> b ;
        cout<<a*b<<endl;


return 0;
}




Measured memory_bytes: 3652
a = ['S','H','C','D']
b =[]
for i in range(4):
    for j in range(1,14):
        b.append(str(a[i])+' '+str(j))
n = int(input())
for i in range(n):
    c = input()
    b.remove(c)
for i in range(len(b)):
    print(b[i])


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
const int maxn=200005;
int num[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        if(x>n) continue;
        num[x]++;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        if(num[i]>=i){
            ans+=i;
        }
    }

    printf("%d\n",n-ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
//class 
class DisjointSet{ //クラスの宣言 
public: //公開部分 
  vector<int>rank,p; //メンバ変数の宣言 
  DisjointSet(); //コンストラクタ※ここはなくてもおｋ 
  DisjointSet(int size){ 
    rank.resize(size,0); 
    //resize→要素数を変更 
    p.resize(size,0); 
    //上二行:メンバ変数のrank,pの要素を調整 
    for(int i=0;i<size;++i) makeSet(i); 
  }
  void makeSet(int x){ //メンバ関数"makeSet"の宣言 
    p[x]=x; rank[x]=0; 
  } 
  bool same(int x,int y){ //メンバ関数"same"の宣言 
    return findSet(x)==findSet(y); 
  } 
  void unite(int x,int y){ //メンバ関数"unite"の宣言 
    link(findSet(x),findSet(y)); 
  } 
  void link(int x,int y){ //メンバ関数"link"の宣言 
    if( rank[x]>rank[y]){ 
      p[y]=x; 
    }else{ p[x]=y; 
      if(rank[x]==rank[y]) rank[y]++; 
    } 
  } 
  int findSet(int x){ //メンバ関数"findSet"の宣言 
    if(x!=p[x]) p[x]=findSet(p[x]); 
    return p[x]; 
  } 
}; 
//main関数 
int main(){ 
  int n,a,b,q; 
  int t; 
  cin>>n>>q; 
  DisjointSet ds=DisjointSet(n); 
  //class-DisjointSetでdsを宣言 
  for(int i=0;i<q;++i){ 
    cin>>t>>a>>b; 
    if(t==0) ds.unite(a,b); 
    else if(t==1){ 
      if(ds.same(a,b)) cout<<1<<endl; 
      else cout<<0<<endl; 
    } 
  } 
  return 0; 
} 



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

using namespace std;
typedef long long int ll;

ll N,P;
ll A[60];
ll DP[2][60];

ll count(ll n){
  ll res =0;
  for( ll i = 0;i<N;i++){
    if(A[i]==n)res++;
  }
  return res;
}

ll solve(){
  if( A[0]&1){
    DP[0][0]=1;
    DP[1][0]=1;
  }else{
    DP[0][0]=2;
    DP[1][0]=0;
  }

  for( int i = 1;i<N;i++){
    if(A[i]&1){
      DP[0][i]=DP[0][i-1]+DP[1][i-1];
      DP[1][i]=DP[0][i-1]+DP[1][i-1];
    }else{
      DP[0][i]=DP[0][i-1]*2;
      DP[1][i]=DP[1][i-1]*2;
    }
  }
  
      
  return DP[P][N-1];

}

int main() {

  cin>>N;
  cin>>P;
  for(int i =0;i<N;i++)cin>>A[i];

  cout<<solve()<<endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define rep(i, l, r)  for(int i = l; i <= r; i++)
#define PII pair<int,int>
using namespace std;
const int inf = 0x3f3f3f3f;
const int mod = 1000000007;
const int maxn = 1000005;
inline int read(){
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
const double PI = 3.14159;


int main() {
    int a = read();
    cout << fixed << setprecision(2) << 2*PI*a << endl;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b, c, n, x, y;
  cin >> a >> b >> c;
  if (b - a == c - b)
    YES();
  else
    NO();
  return 0;
}

Measured memory_bytes: 3600
fn main() {
    let n: i32 = read();
    let mut ans = n * 800;
    ans -= n / 15 * 200;
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
n=int(input())
li=[]
while True:
    try:
        li.append(list(map(int,input().split())))
    except:
        break

#ans=Trueにしておいて、チェックにひっ掛かったらFalseに変える
ans=True

#設定より負の値になっていればNO
for i in range(n):
    if li[i][1]>=0 and li[i][2]>=0:
        continue
    ans=False
    print('No')
    break
        
        
#進める最大値よりも先に存在した場合にNOを出す
if ans==True:
    for j in range(n):
        if li[j][0]>=li[j][1]+li[j][2]:
            continue
        ans=False
        print('No')
        break
#秒数とマス目の和の偶奇を調べる
if ans==True:        
    for k in range(n):
        if li[k][0]%2==(li[k][1]+li[k][2])%2:
            continue
        ans=False
        print('No')
        break
        
if ans==True:
    print('Yes')

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

const int MAX_LEN = 100000;

int main() {
  string s;
  cin >> s;
  int len[4] = { 5, 7, 5, 6 };
  string t[4] = { "dream", "dreamer", "erase", "eraser" };
  bool ok[MAX_LEN+10];
  int slen = s.length();
  for (int i=0; i<=slen; i++) ok[i] = false;
  ok[0] = true;

  for (int i=0; i+5<=slen; i++) {
    if (ok[i]) {
      for (int j=0; j<4; j++) {
        if (ok[i+len[j]]) continue;
        bool tmp = true;
        for (int k=0; k<len[j]; k++) {
          if (t[j][k] != s[i+k]) {
            tmp = false;
            break;
          }
        }
        ok[i+len[j]] = tmp;
      }
    }
  }
  // for (int i=1; i<=slen; i++) {
  //   cout << (ok[i]?1:0);
  // } cout << endl;
  cout << (ok[slen]?"YES":"NO") << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}
int main() {
    string S;
    cin >> S;
    int N = S.size();
    int m = 2019;
    int p = 1;
    reverse(WHOLE(S));
    vector<int> a(N);
    for(int i = 0; i < N; i++) {
        a[i] = ( (S[i] - '0') * p + (i ? a[i - 1] : 0)) % m;
        p *= 10;
        p %= m;
    }
    reverse(WHOLE(a));
    a.push_back(0);
    map<int, i64> mp;
    for(int i = 0; i < N + 1; i++) {
        mp[a[i]]++;
    }
    i64 ans = 0;
    for(auto x : mp) {
        ans += (x.second * (x.second - 1)) / 2;
    }
    cout << ans << endl;
    
    return 0;
}



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

int main() {
  char x;
  cin >> x;
  
  if (isupper(x)){
      cout << "A" << endl;
  }
  else {
      cout << "a" << endl;
  }
}

Measured memory_bytes: 3564
#include <random>
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld eps = 1e-12;
constexpr int inf = numeric_limits<int>::max() / 2;
constexpr ll mod = 1e9 + 7;
mt19937_64 rnd{random_device()()};

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  string s;
  cin >> s;
  int n = s.size();
  s = "$" + s;
  if (s[1] == '0' || s[n] == '1') {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 1; i < n; i++) {
    if (s[i] != s[n - i]) {
      cout << -1 << endl;
      return 0;
    }
  }
  vector<int> pos;
  for (int i = 1; i <= n / 2; i++) {
    if (s[i] == '1') pos.push_back(i);
  }
  pos.push_back(n);
  int sz = pos.size();
  for (int i = 0; i < sz - 1; i++) {
    int u = pos[i], v = pos[i + 1];
    cout << u << " " << v << endl;
    for (int j = u + 1; j < v; j++) {
      cout << j << " " << v << endl;
    }
  }
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  
  int n; cin >> n;

  vector<int> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];

  sort(begin(arr), end(arr));

  int distance = 0;

  for (int i = 0; i < n - 1; ++i) {
    distance += abs(arr[i] - arr[i + 1]);
  }

  cout << distance << "\n";
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

template <unsigned mod>
struct RollingHash
{
    vector<unsigned> hashed, power;

    inline unsigned mul(unsigned a, unsigned b) const
    {
        unsigned long long x = (unsigned long long)a * b;
        unsigned xh = (unsigned)(x >> 32), xl = (unsigned)x, d, m;
        asm("divl %4; \n\t"
            : "=a"(d), "=d"(m)
            : "d"(xh), "a"(xl), "r"(mod));
        return m;
    }

    RollingHash(const string &s, unsigned base = 10007)
    {
        int sz = (int)s.size();
        hashed.assign(sz + 1, 0);
        power.assign(sz + 1, 0);
        power[0] = 1;
        for (int i = 0; i < sz; i++)
        {
            power[i + 1] = mul(power[i], base);
            hashed[i + 1] = mul(hashed[i], base) + s[i];
            if (hashed[i + 1] >= mod)
                hashed[i + 1] -= mod;
        }
    }

    unsigned get(int l, int r) const
    {
        unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
        if (ret >= mod)
            ret -= mod;
        return ret;
    }

    unsigned connect(unsigned h1, int h2, int h2len) const
    {
        unsigned ret = mul(h1, power[h2len]) + h2;
        if (ret >= mod)
            ret -= mod;
        return ret;
    }

    int LCP(const RollingHash<mod> &b, int l1, int r1, int l2, int r2)
    {
        int len = min(r1 - l1, r2 - l2);
        int low = -1, high = len + 1;
        while (high - low > 1)
        {
            int mid = (low + high) / 2;
            if (get(l1, l1 + mid) == b.get(l2, l2 + mid))
                low = mid;
            else
                high = mid;
        }
        return (low);
    }
};

using RH = RollingHash<1000000007>;

bool check(ll x, string &s, RH &rh, int n)
{
    for (int i = 0; i < n - x + 1; i++)
    {
        auto hash1 = rh.get(i, i + x);
        for (int j = i + x; j < n - x + 1; j++)
        {
            auto hash2 = rh.get(j, j + x);
            if (hash1 == hash2)
            {
                return true;
            }
        }
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    RH rh(s);
    int ng = n / 2 + 1;
    int ok = 0;
    while (abs(ok - ng) > 1)
    {
        int mid = (ok + ng) / 2;
        if (check(mid, s, rh, n))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    cout << ok << endl;
}

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

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

    int count = 0;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = 1; j <= s.size() - i; j++)
        {
            string t = s.substr(i, j);
            for (char k : t)
            {
                if (!(k == 'A' || k == 'C' || k == 'G' || k == 'T'))
                {
                    goto end;
                }
            }
            count = max(count, (int)t.size());
        end:
            continue;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    ll out=0;
    for(int i=1;i<=N;i++){
        if(i%3==0 || i%5==0){

        }else{
            out += i;
        }
    }
    cout << out << endl;
    return 0;
}


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

typedef	long long ll;

bool works(ll n, ll k)
{
	while (n%k==0)
		n/=k;
	return n==1 or n%k==1;
}

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	ll N;
	cin >> N;
	ll sol(0);
	for (ll K(1); K*K <= N; ++K)
	{
		if (N%K==0)
		{
			if (K > 1)
				sol += works(N,K);
			if (N/K != K)
				sol += works(N,N/K);
		}
	}
	for (ll K(1); K*K<=N-1; ++K)
	{
		if ((N-1)%K==0)
		{
			sol += K>1;
			if ((N-1)/K != K)
				sol += 1;
		}
	}
	cout << sol << endl;
}



Measured memory_bytes: 256
// 166 B

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;

int main(){
    int n, k, buf, count=0, tmp;
    cin >> n >> k;
    vector<bool> list(n, true);
    for(int i=0; i<k; i++){
        cin >> buf;
        for(int j=0; j<buf; j++){
            cin >> tmp;
            list.at(tmp-1) = false;
        }
    }
    for(int i=0; i<n; i++){
        if(list.at(i)) count++;
    }
    cout << count << endl;
    return 0;

}

Measured memory_bytes: 3600
###############################################################################

from bisect import bisect_left as binl

def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * sy) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


###############################################################################


def main():
    poslist = intinl(5)
    k = intin()

    for i in poslist:
        for j in poslist:
            if abs(j - i) > k:
                print(':(')
                return 0

    print('Yay!')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll          long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}


int main() {

    ISO();
    online_judge();
    string s,t;
    cin >> s >> t;
    int n = s.length();
    int k = t.length();
    if(n == 1)
    {
        (s[0] == t[0])?(cout << 0 <<"\n"):(cout << 1 <<"\n");
        return 0;
    }
    else if(n == k)
    {
        int cost = 0;
        for(int i=0;i<n;++i)
        {
            if(s[i]!=t[i])
            {
                cost++;
            }
        }
        cout << cost <<"\n";
        return 0;
    }
    vector <int> ans;
    for(int i = 0;i < (n-k);++i)
    {
        ll cost = 0;
        for(int j=i;j<i+k;++j)
        {
            if(s[j] == t[j-i])
            {
                continue;
            }
            else
            {
                cost++;
            }
        }
        ans.push_back(cost);
    }
    sort(ans.begin(),ans.end());
    cout << ans[0] <<"\n";






    //cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
    return 0;
}

Measured memory_bytes: 3664
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int s = a*b;
			int syu = (a+b)*2;
			System.out.println(s + " " + syu);
		}
	}
}

Measured memory_bytes: 25932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str1 = scan.next();
		String str2 = scan.next();
		String str3 = scan.next();
		int a = Integer.parseInt(str1);
		int b = Integer.parseInt(str2);
		int c = Integer.parseInt(str3);
		if (a < b &&b<c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}



Measured memory_bytes: 26164
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,n,a) for(int i=n;i>=a;i--)
#define endl '\n'
#define eps 0.000000001
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a))
#define IO ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const int INF=0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int maxn=1e5+5;
int a[maxn];
int main(){
	int n,k;cin>>n>>k;
	rep(i,1,n) cin>>a[i];
	sort(a+1,a+n+1);
	ll sum=0;
	rep(i,1,k){
		sum+=a[i];
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 3636
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N, x = ri_()
a = sorted(ri_())
ans = 0
for i in range(N):
    if i < N - 1:
        x -= a[i]
        if x >= 0:
            ans += 1
        else:
            break
    else:
        if x == a[i]:
            ans += 1
print(ans)

Measured memory_bytes: 9196
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define lli long long int
#define ld long double
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    string s;
    cin>>s;
    bool ok = 1;
    if((lli)s.size() & 1) ok = 0;
    for(int i = 0; i + 1 < s.size(); i += 2)
        if(s[i] == 'h' && s[i + 1] == 'i');
        else ok = 0;
    if(ok)
        cout<<"Yes";
    else
        cout<<"No";
    cout<<'\n';
    return ;
}



/*
*/

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

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		char ch[][]=new char[8][8];
		for(int i=0;i<8;i++){
			ch[i]=sc.next().toCharArray();
		}
		turn(ch,1);
	}
	static void turn(char ch[][],int k){
		if(3<k) return;
		char turn[][]=new char[8][8];
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				turn[i][j]=ch[7-j][i];
			}
		}
		System.out.println(k*90);
		for(int i=0;i<8;i++){
			for(int j=0;j<8;j++){
				System.out.print(turn[i][j]);
			}
			System.out.println();
		}
		turn(turn,k+1);
	}
}

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

using namespace std;

using ll = long long;
using ld = long double;

using pll = pair<ll, ll>;
using vll = vector<ll>;
using vpll = vector<pll>;
using gr = vector<vll>;
using wgr = vector<vpll>;

#define pb push_back
#define FOR(i, m, n) for (ll i(m); i < n; i++)
#define REP(i, n) FOR(i, 0, n)
#define F(n) REP(i, n)
#define FF(n) REP(j, n)
struct d_ {
    template<typename T> d_ & operator ,(const T & x) { cerr << ' ' <<  x; return *this;}
    template<typename T> d_ & operator ,(const vector<T> & x) { for(auto x: x) cerr << ' ' <<  x; return *this;}
} d_t;
#define dbg(args ...) { d_t,"|",__LINE__,"|",":",args,"\n"; }
#define EPS (1e-10)
#define INF (1LL<<61)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define all(x) begin(x),end(x)
#define IN(n) ll n;cin >> n;
#define x first
#define y second

int main(void) {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    if(n>999) cout << "ABD" << endl;
    else cout << "ABC" << endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 1000000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<ll>>;

vector<ll> d(2010, 0);//最短距離を格納する配列
vector<ll> d2(2010, 0);
vector<bool> seen(2010, false);
vector<bool> seen2(2010, false);

vector<ll> ans(2010); //ans[i]は二頂点間の距離がiの、頂点の組の個数

//始点vから幅優先探索
void bfs(const Graph &G, int v) {

	seen[v] = true; //vを訪問済みにする
	d[v] = 0; //始点の距離0

	queue<int> que;
	que.push(v); //始点vをキューに突っ込む

	while (que.size()){
		int iSentou = que.front();
		que.pop();

		//キューの先頭から行ける各頂点next_vについて
		for (auto next_v : G[iSentou]) {
			if (seen[next_v]) continue; //訪問済みだったらスルー

			que.push(next_v); //移動後の点をキューに入れる
			d[next_v] = d[iSentou] + 1;//距離を移動前+1で確定
			seen[next_v] = true;
           	ans[d[next_v]]++;
		}
	}
}


int main() {
	int N, X, Y;
	cin >> N >> X >> Y;

	Graph G(N + 1);
	G[1].push_back(2);
	G[N].push_back(N - 1);

	for (int i = 2; i <= N - 1; i++) {
		G[i].push_back(i + 1);
		G[i].push_back(i - 1);
	}
	G[X].push_back(Y);
	G[Y].push_back(X);

	for (int v = 1; v <= N; v++) {
		bfs(G, v);
		d = d2;
      	seen = seen2;
	}

	for (int i = 1; i <= N - 1; i++) {
		cout << ans[i] / 2 << endl;
	}

}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)

using namespace std;
typedef long long ll;

ll cal[110000], calrev[110000];
ll calma[110000], calmarev[110000];
ll dist[110000], distrev[110000];
ll v[110000];
ll N, C;

int main()
{
  cin >> N >> C;
  for (int i = 1; i <= N; i++) cin >> dist[i] >> v[i];
  for (int i = 1; i <= N; i++) distrev[i] = C - dist[N - i + 1];

  REP(i, N) {
    cal[i + 1] = cal[i] - (dist[i + 1] - dist[i]) + v[i + 1];
    calma[i + 1] = max(calma[i], cal[i + 1]);
  }
  REP(i, N) {
    calrev[i + 1] = calrev[i] - (distrev[i + 1] - distrev[i]) + v[N - i];
    calmarev[i + 1] = max(calmarev[i], calrev[i + 1]);
  }

  ll ans = 0;
  for (int i = 0; i <= N; i++) {
    ans = max(ans, cal[i]);
    ans = max(ans, cal[i] - dist[i] + calmarev[N - i]);
    ans = max(ans, calrev[i]);
    ans = max(ans, calrev[i] - distrev[i] + calma[N - i]);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 5888
n = gets.chomp.to_i
x = gets.chomp.split.map(&:to_i)

res = 1<<30

x.sort!

(x[0]..x[-1]).each do |i|
  t = 0
  x.each do |xi|
    t += (xi - i) ** 2
  end
  res = [res, t].min
end

puts res

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#define mp make_pair
#include <iostream>
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


LL POW(LL x,LL y)
{
    LL ans=1;
    LL base=x;
    while(y)
    {
        if(y&1)
        {
            ans*=base;
        }
        base=base*base;
        y=y>>1;
    }
    return ans;
}



int main()
{    
    fastinput;
    LL n,i,j,k,t,temp,tc;
    cin>>n>>k;
    if(n<=k)
    {
        cout<<min(n,(LL)fabs(n-k))<<endl;
    }
    else
    {
        n%=k;
        cout<<min(n,(LL)fabs(n-k))<<endl;

    }
    
    


    
    return 0;
}


Measured memory_bytes: 3644
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
h=get_i.reverse!
flag=true
(n-1).times do|i|
  unless h[i]>=h[i+1]
    h[i+1]-=1
    unless h[i]>=h[i+1]
      flag=false
      break
    end
  end
end
puts yn_judge(flag)

Measured memory_bytes: 9612
#include<set>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j,k;
  string s;
  while(getline(cin,s)){
    int ln=s.length();
    for(i=0;i<ln;i++){
      if(0){
      }else if(s[i]>='a'&&s[i]<='z'){
	s[i]+='A'-'a';
      }else if(s[i]>='A'&&s[i]<='Z'){
      }else{
	s.erase(i,1);
	i--;
	ln--;
      }
    }
    set<string,greater<string> > a;
    set<string> b;
    for(i=ln;i>2;i--){
      for(j=0;j<ln-i+1;j++){
	if(b.find(s.substr(j,i))==b.end()){
	  for(k=0;k<i/2;k++){
	    if(s[j+k]!=s[j+i-1-k])
	      break;
	  }
	  if(k==i/2){
	    a.insert(s.substr(j,i));
	    for(k=1;i-k*2>1;k++)
	      b.insert(s.substr(j+k,i-k*2));
	  }
	}
      }
    }
    if(a.empty()==0){
      set<string>::iterator it;
      cout<<*a.begin();
      for(it=a.begin(),it++;it!=a.end();it++)
	cout<<" "<<*it;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 932
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
	long long n;
	cin >> n;
	long long x=n/5;
	long long ans=n*(n+1)/2;
	ans-=x*(x+1)/2*5;
	x=n/3;
	ans-=x*(x+1)/2*3;
	x=n/15;
	ans+=x*(x+1)/2*15;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3188