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

const int maxn = 40;
uint64_t adj[maxn];
int n, m, c[maxn], sum[2][1 << 20];

int Eval(uint64_t mask) {
    return sum[0][mask & ((1LL << (n / 2)) - 1)] + sum[1][mask >> (n / 2)];
}

int dfs(int x, uint64_t ng, uint64_t f) {
    if (x == n - 1) return Eval(ng);
    uint64_t cand = (adj[x] & ~f);
    int res = 1E9;
    while (cand > 0) {
        int u = __builtin_ctzll(cand & -cand);
        if (u != x)
            res = min(res, dfs(u, ng | adj[x] | adj[u], (adj[x] ^ (1ULL << u)) | f));
        cand -= (1ULL << u);
    }
    return res;
}

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; ++i) scanf("%d", &c[i]);
    for (int i = 0; i < n; ++i) adj[i] |= (1ULL << i);
    for (int i = 0; i < m; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        --u, --v;
        adj[u] |= (1ULL << v);
        adj[v] |= (1ULL << u);
    }
    for (int i = 0; i < (1 << (n / 2)); ++i) {
        for (int j = 0; j < n / 2; ++j) {
            if (i >> j & 1)
                sum[0][i] += c[j];
        }
    }
    for (int i = 0; i < (1 << (n - n / 2)); ++i) {
        for (int j = 0; j < n - n / 2; ++j) {
            if (i >> j & 1)
                sum[1][i] += c[j + n / 2];
        }
    }
    printf("%d\n", dfs(0, 0LL, 0LL));
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<int> s(n, 0);

	for(int i = 0; i < k; ++i)
	{
		int d;
		cin >> d;
		for(int j = 0; j < d; ++j)
		{
			int a;
			cin >> a;
			s[a - 1] = 1;
		}
	}

	int ans = n;
	for(const auto& v : s)
	{
		ans -= v;
	}

	cout << ans << endl;


}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3592
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> s(M,0);
    vector<ll> t(M,0);
    for(ll i=0;i<M;++i)cin>>s[i]>>t[i];
    for(ll i=0;i<M;++i){s[i]--;t[i]--;}
    vector<vector<ll>> G(N, vector<ll>(0));
    for(ll i=0;i<M;++i)G[s[i]].emplace_back(t[i]);
    ld ans;
    vector<ld> dp1(N,-1.0);
    dp1[N-1]=0.0;
    function<ld(ll)> E1 = [&](ll f){
        if(dp1[f]!=-1.0)return dp1[f];
        ll k=G[f].size();
        ld sum=0;
        for(auto p: G[f]){
            sum+=E1(p);
        }
        return dp1[f]=1.0+sum/k;
    };
    ans=E1(0);
    vector<vector<ld>> vec(N, vector<ld>(0));
    for(ll i=0;i<N;++i){
        for(auto p: G[i])vec[i].emplace_back(E1(p));
        sort(vec[i].rbegin(), vec[i].rend());
    }
    for(ll i=0;i<N;++i){
        if(G[i].size()==1)continue;
        vector<ld> dp(N,-1.0);
        dp[N-1]=0.0;
        function<ld(ll)> E = [&](ll f){
            if(dp[f]!=-1.0)return dp[f];
            ll k=G[f].size();
            if(f==i)k--;
            ld sum=0.0;
            for(auto p: G[f]){
                sum+=E(p);
            }
            if(f==i)sum-=vec[i][0];
            return dp[f]=1.0+sum/k;
        };
        chmin(ans,E(0));
    }
    cout << fixed << setprecision(15);
    prt(ans);


    return 0;
}



Measured memory_bytes: 12124
#include <iostream>

using namespace std;

int V[30] = {0};
int C[30] = {0};
int g[30] = {0};

int main()
{
	int N;
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> V[i];
		
	for (int i = 0; i < N; i++)
	{
		cin >> C[i];
		g[i] = V[i] - C[i];
	}
	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		if (g[i] > 0)
			ans += g[i];
	}
	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int> vi;
vector<int> :: iterator vit;
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int x,y,i,j,a,b;
    cin>>x>>y;
    char str[x][y],str2[100][100],str3[100][100],str4[100][100],str5[100][100];

    for(i=0;i<x;i++){
        for(j=0;j<y;j++){
            cin>>str[i][j];
        }
    }
    int cnt=0,k=0;
    for(i=0;i<x;i++){
        cnt=0;
        for(j=0;j<y;j++){
            if(str[i][j]=='.'){
                cnt++;
            }
            else{
                cnt=0;
                break;
            }
        }
        if(cnt==y){

        }
        else{
            for(j=0;j<y;j++){
                str2[k][j]=str[i][j];
            }
            k++;
            cnt=0;
        }
    }
    /*
    cout<<k<<" "<<y<<endl;
    for(i=0;i<k;i++){
        for(j=0;j<y;j++){
            cout<<str2[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
    */
    a=0;
    b=0;
    for(i=y-1;i>=0;i--){
        b=0;
        for(j=k-1;j>=0;j--){
            str3[a][b]=str2[j][i];
            b++;
        }
        a++;
    }
    /*
    cout<<a<<" "<<b<<endl;
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cout<<str3[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
    */
    cnt=0;
    k=0;
    for(i=0;i<a;i++){
        cnt=0;
        for(j=0;j<b;j++){
            if(str3[i][j]=='.'){
                cnt++;
            }
            else{
                cnt=0;
                break;
            }
        }
        if(cnt==b){

        }
        else{
            for(j=0;j<b;j++){
                str4[k][j]=str3[i][j];
            }
            k++;
        }
    }
    /*
    cout<<k<<" "<<b<<endl;
    for(i=0;i<k;i++){
        for(j=0;j<b;j++){
            cout<<str4[i][j];
        }
        cout<<endl;
    }
    */
    x=a;
    y=b;
    a=0;
    b=0;
    for(i=y-1;i>=0;i--){
        b=0;
        for(j=k-1;j>=0;j--){
            str5[a][b]=str4[j][i];
            b++;
        }
        a++;
    }
    //cout<<a<<" "<<b<<endl;
    for(i=0;i<a;i++){
        for(j=0;j<b;j++){
            cout<<str5[i][j];
        }
        cout<<endl;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Main main = new Main();
    main.solve();
  }
  public void solve() {
    Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
    int N = scan.nextInt();
    int K = scan.nextInt();
    if (K == 1) {
      System.out.println("YES");
      return;
    }
    if (K * 2 - 1 <= N) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}


Measured memory_bytes: 21844
N = int(input())
CSF = []
for n in range(N-1):
  CSF.append([int(csf) for csf in input().split()])

for i in range(N-1):
  total_time = 0
  for j in range(i, N-1):
    c12, s1, f1 = CSF[j]
    if s1 >= total_time:
      total_time = s1 + c12
    else:
      how_many_arrival_train = (total_time - s1) // f1
      how_long_waiting_time = (total_time - s1) % f1
      if how_long_waiting_time == 0:
        total_time = s1 + f1 * how_many_arrival_train + c12
      else:
        total_time = s1 + f1 * (how_many_arrival_train + 1) + c12
  print(total_time)
print(0)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int h[100010];
bool notgood[100010];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	scanf("%d",&h[i]);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		if(h[x]>=h[y])notgood[y]=1;
		if(h[x]<=h[y])notgood[x]=1;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	if(!notgood[i])ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4312
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
 
#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647
 
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);
ll power(ll x, unsigned long long y)
{
    int res = 1;     // Initialize result
 
    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x);
 
        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x);  // Change x to x^2
    }
    return res;
}
 
 
map<ll, ll> mp;
vector<ll>v;
void solve()
{
    ll n, m, k, pos, pos1;
 
    cin >> n >> k;
    ll a[n+10], p[n+10];
    int f = 0;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> a[i];
        p[a[i]] = i;
 
    }
 
    ll i = 1;
    m = k;
    while(m--)
    {
        if(a[i] == i)
        {
         //cout << a[i] << endl;
          f = 1;
          break;
        }
        //cout << a[i] << endl;
        if(mp.find(a[i]) != mp.end())
        {
            pos = a[i];
            break;
        }
        v.pb(a[i]);
        mp[a[i]] = 1;
        i = a[i];
    }
    //cout << m << endl;
    if(f) cout << a[i] << endl;
    else if(m == -1) cout << i << endl;
    else
    {
        for(int i = 0 ; i < v.size() ; i++)
        {
            if(v[i] != pos) k--;
            else
            {
                pos1 = i;
                break;
            }
 
        }
        if(v.size() == 1) cout << v[0] << endl;
        else
        {
            ll diff = v.size() - pos1;
            k %= diff;
            if(k == 0) k = diff;
            cout << v[pos1 + k - 1] << endl;
        }
 
    }
 
 
}
 
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
    return 0;
}


Measured memory_bytes: 17536
#include<cstdio>
#include<string.h>
#include<algorithm>
#include<vector>
#include<functional>
#include<queue>
using namespace std;

const double INF = 1e9;
typedef double Weight;

struct Edge{
  int src,dst;
  Weight weight;
  Edge(int src,int dst,Weight weight) : src(src), dst(dst), weight(weight) {;}
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void dijkstra(const Graph &g,const int s, vector<Weight> &dist, vector<int> &prev,int ts,int b) {
  const int n = g.size();
  dist.assign(n, INF);
  dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q;

  for(Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top();
    Q.pop();
    if(prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    if(e.dst/ts == b) {
      printf("%.4f\n", dist[e.dst]);
      return;
    }

    for(Edges::const_iterator it = g[e.dst].begin(); it != g[e.dst].end(); ++it) {
      if(dist[it->dst] > e.weight + it->weight) {
	dist[it->dst] = e.weight + it->weight;
	Q.push(Edge(it->src, it->dst, e.weight + it->weight));
      }
    }
  }
  printf("Impossible\n");
}

int main() {
  int n,m,p,a,b,ts,t,x,y,z;
  vector<int> tickets(8);
  vector<int> prev((1<<8)*30);
  vector<Weight> dist((1<<8)*30);

  while(scanf("%d %d %d %d %d", &n, &m, &p, &a, &b)) {
    if(n==0 && m==0 && p==0 && a==0 && b==0) break;
    ts = 1<<n;
    Graph g(ts*m);
    a--,b--;

    tickets.clear();
    for(int i=0; i<n; ++i) {
      scanf("%d", &t);
      tickets.push_back(t);
    }

    for(int i=0; i<p; ++i) {
      scanf("%d %d %d", &x, &y, &z);
      x--,y--;
      for(int j=0; j<ts; ++j) {
	for(int k=0; k<n; ++k) {
	  if((j&(1<<k)) == 0) {
	    g[x*ts+j].push_back( Edge(x*ts+j, y*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	    g[y*ts+j].push_back( Edge(y*ts+j, x*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	  }
	}
      }
    }

    dist.clear();
    prev.clear();
    dijkstra(g, a*ts, dist, prev, ts, b);

    /*
    double minw = INF;
    for(int i=0; i<ts; ++i)
      minw = min(dist[b*ts+i], minw);

    if(minw == INF)
      printf("Impossible\n");
    else
      printf("%f\n", minw);
    */
  }
}

Measured memory_bytes: 29000
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : September 10, 2020 4:54 PM
 *    Problem Name  : B - I miss you...
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc154/tasks/abc154_b
 *    @genarated by : ai-virtual-assistant
**/

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

int main(){
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    for(int i=0; i<s.length(); i++) {
        cout << "x";
    }
    cout << endl;
    return 0 ;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define INF = 1001001001
#define pi = acos(-1)
using namespace std;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return (x * y) / gcd(x, y); }


int main(){
    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    ll min = 1000000001;
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }

    sort(h.begin(), h.end());
    for (int j = 0; j < n-k+1; ++j) {
        if(h[j+k-1]-h[j] < min) min = h[j+k-1] - h[j];
    }

    cout << min << endl;
}


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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector <int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }

  bool flag_z = true;
  bool flag_e = true;
  int cnt = 0;
  while(flag_e){
    flag_e = false;
    flag_z = false;
    int cur;
    for(int i = 0; i < N; i++){
      if(vec.at(i) != 0){
	flag_e = true;
	flag_z = true;
	cur = i;
	vec.at(i)--;
      }else{
	if(flag_z){
	  cnt++;
	  flag_z = false;
	}
      }
    }
    if(flag_z) cnt++;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#define ll long long
#define fr(i,p,n) for(int i=p;i<n;i++)
#define fr1(i,p,n) for(int i=p;i>=n;i--)
#define FAST ios::sync_with_stdio(0);
#define sz(v) (ll)v.size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define PI 3.14159265358979323846
#define mod 1000000007
#define mod1 998244353
#define precise cout << std::setprecision(12) << std::fixed;
#define endl "\n"
using namespace std;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    FAST
    int t=1;
    //cin>>t;
    while(t--)
    {
        int h,w,k;
        cin>>h>>w>>k;
        char ch[h][w];
        int b=0;
        fr(i,0,h)
        {
            fr(j,0,w)
            {
                cin>>ch[i][j];
                if(ch[i][j]=='#') b++;
            }
        }
        int ans=0;
        fr(i,0,(1<<h))
        {
            int x[6]={0};
            int temp=i;
            int cnt=0;
            while(temp!=0)
            {
                x[cnt]=temp%2;
                cnt++;
                temp/=2;
            }
            fr(j,0,(1<<w))
            {
                int y[6]={0};
                temp=j;
                cnt=0;
                while(temp!=0)
                {
                    y[cnt]=temp%2;
                    cnt++;
                    temp/=2;
                }
                int res=b;
                char ch1[h][w];
                fr(i1,0,h) fr(j1,0,w) ch1[i1][j1]=ch[i1][j1];
                fr(i1,0,h)
                {
                    if(x[i1]==1)
                    {
                        fr(j1,0,w)
                        {
                            if(ch1[i1][j1]=='#') res--;
                            ch1[i1][j1]='R';
                        }
                    }
                }
                fr(i1,0,w)
                {
                    if(y[i1]==1)
                    {
                        fr(j1,0,h)
                        {
                            if(ch1[j1][i1]=='#') res--;
                            ch1[j1][i1]='R';
                        }
                    }
                }
                if(res==k) ans++;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
inline char tc(void){
	static char fl[10000],*A=fl,*B=fl;
	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;	
}
inline int read(void){
	int a=0;static char c;
	while((c=tc())<'0'||c>'9');
	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();
	return a;
}
int n,m,o[200001],w[200001];
int main(void){
	register int i,x,y;
	n=read(),m=read();
	for(i=1;i<=m;++i)
		x=read(),y=read(),x==1?o[y]=1:0,y==n?w[x]=1:0;
	for(i=2;i<n;++i)
		if(o[i]&&w[i]){
			puts("POSSIBLE");
			return 0;
		}
	puts("IMPOSSIBLE");
	return 0;
}


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

    cin >> s; 

    h = s/3600;
    m = (s%3600)/60;
    s = s% 60;

    cout << h << ":" << m << ":" << s << endl;
    


    return 0;
}


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

bool binarySearch(int array[], int arraySize, int searchValue){
	int left=0, right=arraySize, mid;
	while(left < right){
		mid = (left + right) / 2;
		if(array[mid] == searchValue) return true;
		if(array[mid] > searchValue) right = mid;
		else left = mid + 1;
	}
	return false;
}

int main(){
	int n, q;
	cin >> n;
	int s[n];
	for(int i=0; i<n; i++) cin >> s[i];
	cin >> q;
	int t[q];
	for(int i=0; i<q; i++) cin >> t[i];

	int count = 0;
	for(int i=0; i<q; i++){
		if(binarySearch(s, n, t[i])) count++;
	}

	cout << count << endl;

}


Measured memory_bytes: 3656
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		double M = sc.nextDouble();
		double[] A = new double[N];
		double total = 0;
		for( int i=0; i<N; i++ ){
			A[i] = sc.nextDouble();
			total += A[i];
		}
		Arrays.sort(A);
		double P = total/(4*M);
		for( int i=N-1; i>=N-M; i-- ){
			if( A[i]<P ){
				System.out.println("No");
				break;
			}
			if( i==N-M ){
				System.out.println("Yes");
				break;
			}
		}
	}
}

Measured memory_bytes: 23124
S =list(map(int,input().split()))
N=S[0]
M=S[1]

la=[]
for i in range(N):
    la.append(input())
lb=[]
for i in range(M):
    lb.append(input())

c=0
for i in range(N-M+1):
    for j in range(N-M+1):
        flag=True
        for k in range(M):
            for l in range(M):
                if la[i+k][j+l]!=lb[k][l]:
                    flag =False
        if flag==True:
            c+=1

if c>0:
    print("Yes")
if c==0:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
int main(void){
    int n;
    string s;
    cin >> n;
    cin >> s;
    int ans=0;
    int sat=0;
    int ps[3];
    int lay=0;
    for (ps[0] = 0; ps[0] <= 9; ps[0]++)
    {
        for (ps[1] = 0; ps[1] <= 9; ps[1]++)
        {
            for (ps[2] = 0; ps[2] <= 9; ps[2]++)
            {
                sat=0;
                lay=0;
                while(sat <n){
                    if(s.at(sat)-'0'==ps[lay]){
                        lay++;
                       // cout<< s.at(sat)<<" ";
                    }
                    sat++;
                    if(lay>=3){
                        ans++;
                        break;
                    }
                }
              //  cout <<endl;
            }
        }
    }
    cout << ans <<endl;
}


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

int main(){
  vector<int> v(3);
  int f = 0, s = 0;
  cin >> v[0] >> v[1] >> v[2];
  for(int i = 0; i < 3; i++){
    if(v[i] == 5){
      f++;
    }
    if(v[i] == 7){
      s++;
    }
  }
  if(f == 2 && s == 1){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]pub mod pcl{}
fn main() {
    let (n, m) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let sp: Vec<_> = s
            .split_whitespace()
            .map(|x| x.parse::<i32>().unwrap())
            .collect();
        (sp[0], sp[1])
    };
    println!("{}", n * (n - 1) / 2 + m * (m - 1) / 2);
}



Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main(){
	int b[100000];
	int a;
	cin >> a;
	int x=a/2;
	int y = x-1;
	for(int i = 0;i<a;i++){
		cin >> b[i];
	}
	sort(b,b+a);
	cout << (b[x]-b[y]);
	return 0;
} 

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

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

int main(){
	int n,m;
	cin>>n>>m;
	int l[m],r[m],d[m];
	vector<pii> edge[n];
	rep(i,m){
		cin>>l[i]>>r[i]>>d[i];
		l[i]--;r[i]--;
		edge[l[i]].pb(pii(r[i],d[i]));
		edge[r[i]].pb(pii(l[i],-d[i]));
	}
	int num[n];
	bool flg[n];
	fill(flg,flg+n,false);
	rep(i,n){
		if(flg[i]==true)continue;
		queue<int> que;
		num[i]=0;
		que.push(i);
		int now;
		while(!que.empty()){
			now=que.front();
			que.pop();
			if(flg[now])continue;
			else flg[now]=true;
			rep(j,edge[now].size()){
				if(flg[edge[now][j].first]==false){
					num[edge[now][j].first]=num[now]+edge[now][j].second;
					que.push(edge[now][j].first);
				}
			}
		}
	}
	bool check=true;
	rep(i,m){
		if(num[r[i]]-num[l[i]]!=d[i]){
			check=false;
			break;
		}
	}
	cout<<(check?"Yes":"No")<<endl;
	return 0;
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(ll i = 0; i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,e) for (ll i = s; i < (ll)e; i++)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll a, b; cin >> a >> b;
	if (a <= 0 && 0 <= b) {
		cout << "Zero" << endl;
	} else if(a < 0 && b < 0 && (b - a + 1) % 2 == 1 ) {
		cout << "Negative" << endl;
	} else {
		cout << "Positive" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(ll i=0;i<N;++i)
typedef long long int ll;
const ll INF = 1<<30;

int main(){
    ll N,K; cin >> N >> K;
    ll res = 0;
    rep(i,N){
        ll a; cin >> a;
        if(a >= K) res++;
    }
    cout << res << endl;
}

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

typedef long long ll;

#define pb push_back

int main(){
	while(1){
		ll n,p,j;
		ll sum = 0 , cnt[1002] = {};
		scanf("%lld",&n);
		if(n == 0)break;
		for(int i = 0 ; i < n ; i ++){
			scanf("%lld",&p);
			sum += p;
		}
		for(int i = 0 ; i < n-1 ; i ++){
			scanf("%lld",&j);
			sum += j;
			cnt[j] ++;
		}
		ll ret = sum , num = 1 , t = 0;
		while(num < n){
			while(cnt[t] == 0)t ++;
			sum -= t;
			num ++;
			cnt[t] --;
			ret = max ( ret , sum*num );
		}
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 1196
class UnionFind:
    def __init__(self, size, wtlist):
        self.parent = [-1 for i in range(size)]#非負なら親ノード，負ならグループの要素数
        self.wtsum = wtlist[:] #自頂点が親の場合、連結成分の頂点の重みの和
        self.wtmax = wtlist[:] #自頂点が親の場合、連結成分の頂点の重みの最大値
        self.edgenum = [0]*size #自頂点が親の場合、連結成分の辺の本数
        self.edgewtsum = [0]*size #自頂点が親の場合、連結成分の辺の重みの和
        self.edgewtmax = [0]*size #自頂点が親の場合、連結成分の辺の重みの最大値

        self.valid_edgenum = [0]*size #自頂点が親の場合、「有効な辺の数」

    def root(self, x): #root(x): xの根ノードを返す．
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.root(self.parent[x]) #xをxの根に直接つなぐ
            return self.parent[x]

    def merge(self, x, y, m): #merge(x,y,m): xとyを「重さmの辺で」連結させる
        x = self.root(x)
        y = self.root(y)
        if x == y:
            self.edgenum[x] += 1 #辺の本数を更新
            self.edgewtsum[x] += m #辺の重みの和を更新
            self.edgewtmax[x] = max(m,self.edgewtmax[x]) #辺の重みの最大値を更新
            return False
        if self.parent[x] > self.parent[y]: #xの要素数がyの要素数より「小さい」とき入れ替える
            x,y=y,x
        self.parent[x] += self.parent[y] #xの要素数を更新
        self.wtsum[x] += self.wtsum[y] #頂点の重みの和を更新
        self.wtmax[x] = max(self.wtmax[x], self.wtmax[y]) #頂点の重みの最大値を更新
        self.edgenum[x] += 1 + self.edgenum[y] #辺の本数を更新
        self.edgewtsum[x] += m + self.edgenum[y] #重みの和を更新
        self.edgewtmax[x] = max(m,self.edgewtmax[x],self.edgewtmax[y]) #辺の重みの最大値を更新

        self.valid_edgenum[x] = self.valid_edgenum[x] + self.valid_edgenum[y] #「有効な辺の数」を更新

        self.parent[y] = x #yをxにつなぐ
        return True

    def issame(self, x, y): #same(x,y): xとyが同じグループにあるならTrue
        return self.root(x) == self.root(y)
        
    def size(self,x): #size(x): xのいるグループの要素数を返す
        return -self.parent[self.root(x)]




n,m=[int(i) for i in input().split()]
X=[int(i) for i in input().split()]
 
edges=[0 for i in range(m)]
for i in range(m):
    edges[i]=[int(i)-1 for i in input().split()]
    edges[i][2] += 1
edges.sort(key=lambda x: x[2])
 
#print(edges)
 
uf = UnionFind(n,X)

for edge in edges:
    x0=edge[0]
    x1=edge[1]
    uf.merge(x0,x1,edge[2])
    r0=uf.root(x0)
#    print(uf.wtsum,uf.edgewtmax)
    if uf.wtsum[r0] >= uf.edgewtmax[r0]:
        uf.valid_edgenum[r0] = uf.edgenum[r0]
#        print("ok")
 
#print(uf.oksize,uf.esize)
 
num=0
for i in range(n):
    if uf.root(i) ==i:
        num += uf.valid_edgenum[i]
#print(uf.valid_edgenum,uf.edgenum)
print(m-num)

Measured memory_bytes: 35836
def main():
    X = int(input())
    x = divmod(X, 100)
    a = [1, 0]
    y = 0
    while a[0] < x[0] or a[0] == x[0] and a[1] < x[1]:
        i, a[1] = divmod(a[1] + a[0], 100)
        a[0] += i
        y += 1
    return y


print(main())


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

struct E {
  int to, co;
  E(int to=0, int co=0) : to(to), co(co) {}
};

string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}

int main() {
  int m;
  cin >> m;
  vector<string> s(m);
  vector<int> c(m);
  rep(i,m) cin >> s[i] >> c[i];
  rep(i,m) {
    s.push_back(rev(s[i]));
    c.push_back(c[i]);
  }
  int n = 1;
  vector<vector<int>> id(m*2);
  rep(i,m*2) {
    int l = s[i].size();
    id[i].resize(l);
    rep(j,l) {
      id[i][j] = n++;
    }
  }

  vector<vector<E>> g(n);
  rep(i,m*2) {
    int l = s[i].size();
    rep(j,l) {
      int v = id[i][j];
      rep(ni,m*2) {
        if (i/m == ni/m) continue;
        int nl = s[ni].size();
        int w = min(nl, l-j);
        if (s[i].substr(j,w) != s[ni].substr(0,w)) continue;
        int u = 0;
        if (nl > w) {
          u = id[ni][w];
        } else if (l > j+w) {
          u = id[i][j+w];
        } else u = 0;
        // printf("%d -> %d\n", v, u);
        g[v].emplace_back(u,c[ni]);
      }
    }
  }

  const ll INF = 1e18;
  vector<ll> dist(n, INF);
  priority_queue<P, vector<P>, greater<P>> q;
  auto push = [&](int v, ll x) {
    if (dist[v] <= x) return;
    dist[v] = x;
    q.emplace(x,v);
  };

  rep(i,m) push(id[i][0], c[i]);
  while (!q.empty()) {
    ll x = q.top().first;
    int v = q.top().second; q.pop();
    if (dist[v] != x) continue;
    for (E e : g[v]) push(e.to, x+e.co);
  }

  ll ans = dist[0];
  rep(i,m*2) {
    int l = s[i].size();
    rep(j,l) {
      string t = s[i].substr(j);
      if (t == rev(t)) {
        ans = min(ans, dist[id[i][j]]);
      }
    }
  }

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

Measured memory_bytes: 3692
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring> 
#include <algorithm>
using namespace std;
int dp[101][10001] = { 0 };
int main() {
	int N,W;
	int v[101] = {0};
	int w[101] = {0};
	scanf("%d%d", &N,&W);
	for (int i = 1;i <= N; ++i) scanf("%d%d", &v[i], &w[i]);
	for (int i = 1;i <= N;++i) {
		for (int q = 1;q <= W;++q) {
				if (q - w[i] >= 0) {
					dp[i][q] = max(dp[i - 1][q], dp[i - 1][q - w[i]] + v[i]);
				}
				else {
					dp[i][q] = dp[i - 1][q];
				}
			}
	}
	printf("%d\n", dp[N][W]);
	return 0;
}


Measured memory_bytes: 4936
// Pratiyush Mishra(pratiush7)
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repab(i,a,b) for(ll i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define pr1(x) cout<<fixed<<setprecision(15)<<x<<'\n'
#define mod 1000000007
#define mod1 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getvec(v,n) vector<ll> v(n);for(ll i=0;i<n;i++) cin>>v[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;

ll gcd(ll a,ll b){
  if(b==0)
    return a;
  return gcd(b,a%b);
}

ll lcm(vl &v,ll n){
  ll ans=v[0];
  repab(i,1,n-1){
    ans=(v[i]*ans)/gcd(v[i],ans);
  }
  return ans;
}

int main(){
  fio;
  get(n);get(m);
  getvec(v,n);
  vl tempv(n);
  rep(i,n)
    tempv[i]=v[i]/2;
  ll num=lcm(tempv,n);
  bool flag=true;
  rep(i,n){
    double x=(double)num/(double(v[i]));
    if(x-0.5!=floor(x))
      flag=false;
  }
  if(!flag){
    p1(0);
    return 0;
  }
  ll max_num=(m/num);
  ll ans=(max_num+(max_num%2))/2;
  p1(ans);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef pair<int,int> P;
int w,h;
int grid[21][21];
P start,goal;
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
bool isvalid(int x,int y){
  return (x>=0&&x<w&&y>=0&&y<h);
}
int dfs(P p, int t){
  if(p == goal) return t;
  if(t > 10) return t;
  int ret = 100;
  int x = p.first;
  int y = p.second;
  REP(r,4){
    int nx = x + dx[r];
    int ny = y + dy[r];
    if(isvalid(nx,ny) && grid[ny][nx] != 1){
      while(isvalid(nx,ny)){
        if(grid[ny][nx] == 3 ||
            (isvalid(nx+dx[r],ny+dy[r]) && grid[ny+dy[r]][nx+dx[r]] == 1)){
          if(grid[ny][nx] != 3) grid[ny+dy[r]][nx+dx[r]] = 0;
          ret = min(ret,dfs(P(nx,ny),t+1));
          if(grid[ny][nx] != 3) grid[ny+dy[r]][nx+dx[r]] = 1;
          break;
        }
        nx += dx[r];
        ny += dy[r];
      }
    }
  }
  return ret;
}
int main(){
  while(cin>>w>>h,w){
    REP(y,h)REP(x,w){
      cin>>grid[y][x];
      if(grid[y][x]==2){
        start = P(x,y);
      }
      if(grid[y][x]==3){
        goal = P(x,y);
      }
    }
    int ans = dfs(start,0);
    if(ans > 10) ans = -1;
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main()
{
   int z,a,b;
   cin>>z>>a>>b;
   if(a>=b)
  cout<<"delicious"<<endl;
  
   else if(a+z<b)
    cout<<"dangerous"<<endl;
   
   else
    cout<<"safe"<<endl;


    return 0;
}


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

using namespace std;

int main() {
	int n; scanf("%d", &n);
	bool flag = true;
	for(int i = 1, x; i <= n; ++i) {
		scanf("%d", &x);
		if(~x & 1) {
			if(x % 3 && x % 5)
				flag = false;
		}
	}
	puts(flag ? "APPROVED" : "DENIED");
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 22;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int AS = 500000;
int dat[2 * AS];

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


	fread(cn, 1, cm, stdin);
	int N = getint();

	auto da = dat + AS;
	rep(i, N) da[i] = (1 << *ci++ - 'a');
	ci++;

	for (int i = AS - 1; i >= 1; i--) dat[i] = dat[i << 1] | dat[(i << 1) + 1];
	int Q = getint();

	rep(j, Q) {
		char q = *ci++;
		ci++;
		if (q == '1') {
			int i = getint() - 1 + AS;
			for (dat[i] = 1 << *ci++ - 'a'; i > 1; i >>= 1) dat[i >> 1] = dat[i] | dat[i ^ 1];
			ci++;
		}
		else {
			int ret = 0;
			for (int l = getint() - 1 + AS, r = getint() + AS; l < r; l >>= 1, r >>= 1) {
				if (l & 1) ret |= dat[l++];
				if (r & 1) ret |= dat[--r];
			}
			printf("%d\n", __builtin_popcount(ret));
		}
	}

	Would you please return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
    int N;
    char A[300005];
    int B[300005];
    while(scanf("%d",&N)!=EOF)
    {
        memset(A,'\0',sizeof(A));
        memset(B,0,sizeof(B));
        scanf("%s",A);

        int cnt=0;
        for(int i=0,cnt=0;i<N;i++)
        {
            B[i]=cnt;
            if(A[i]=='W') cnt++;
        }
        //memset(B,0,sizeof(B));
        for(int i=N-1,cnt=0;i>=0;i--)
        {
            B[i]=B[i]+cnt;
            if(A[i]=='E') cnt++;
        }
        sort(B,B+N);
        printf("%d\n",B[0]);
    }
    return 0;
}


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

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

  int I, N = 0;
  if (a < b) {
    I = a;
    N = b;
  } else {
    I = b;
    N = a;
  }
  for (size_t i = 0; i < N; i++) {
    cout << I;
  }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int M = scanner.nextInt();
			int W = scanner.nextInt();
			if ((M | W) == 0)
				break;
			int[] bm = new int[M];
			for (int i = 0; i < M; i++)
				bm[i] = scanner.nextInt();
			int[] bw = new int[W];
			for (int i = 0; i < W; i++)
				bw[i] = scanner.nextInt();
			int[] dp = new int[1 << W];
				Arrays.fill(dp, -1);
			dp[0] = 0;
			for (int i = 0; i < M; i++) {
				for (int j = (1 << W) - 2; j >= 0; j--) {
					if (dp[j] == -1)
						continue;
					for (int k = 0; k < W; k++) {
						if (((j >> k) & 1) == 1)
							continue;
						int a = j | 1 << k;
						int b = (int) (Math.abs(bm[i] - bw[k]) * Math.pow(
								Math.abs(bm[i] - bw[k]) - 30, 2));
						dp[a] = Math.max(dp[a], dp[j] + b);
					}
				}
			}
			int max = 0;
			for (int i = 0; i < 1 << W; i++) {
				max = Math.max(max, dp[i]);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 22324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vs = vector<string>;
using vvs = vector<vs>;
using pli = pair<long long, int>;
using vpli = vector<pli>;

int main() {
  ll N, a, next = 1;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (a == next) next++;
  }
  
  if (next == 1) cout << -1 << endl;
  else cout << N - next + 1 << endl;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int a[5];
    
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3, greater<int>());
    cout << a[0]*10 + a[1] + a[2]  << endl;
 }


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

bool travel(ll dt, ll dx, ll dy){
  if(dt >= dx + dy)if((dt - dx - dy) % 2 == 0) return true;
  return false;
}

int main(){
  ll n;
  cin >> n;
  vll t(n + 1), x(n + 1), y(n + 1);
  rep(i, 1, n + 1) cin >> t[i] >> x[i] >> y[i];
  t[0] = 0, x[0] = 0, y[0] = 0;
  bool ans = true;
  rep(i, 0, n){
    ll dt = t[i + 1] - t[i], dx = x[i + 1] - x[i], dy = y[i + 1] - y[i];
    if(!travel(dt, dx, dy)) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
}

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

int main(){
	int H,W;
	while(cin >> H >> W){
		if(H==0&&W==0) break;	

		for(int i=0;i<H;i++){
			for(int j=0; j<W; j++){
				if(H==0&&W==0) break;
				cout <<"#";
			}
				cout <<"\n";
	
		}
		cout << "\n";
	}
		
}

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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T>
inline T LCM(T a, T b) { return (a + (b - 1)) / b; }
template<class T>
inline T round_int(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	sort(ASC(a));

	int ai = a.back();
	int aj = a[0];
	rep(i, n - 1) {
		if (abs(a[i] - ai / 2) <= abs(aj - ai / 2)) aj = a[i];
	}
	cout << ai << " " << aj << endl;
}


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

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s.at(0) == s.at(1) && s.at(2) == s.at(3) && s.at(1) != s.at(2)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


N = int(input())
start = []
end = []
itv = []
for i in range(N):
    X, L = (int(i) for i in input().split())
    itv.append([X+L, X-L])
    #start.append(X-L)
    #end.append(X+L)

#XL = [[int(i) for i in input().split()] for i in range(N)] 

#line = [0] * (2*(10**9) +1)

itv.sort()

#print(itv)

ass = 0
tt = 0-10**9
for i in range(N):
    if tt <= itv[i][1]:
        ass += 1
        tt = itv[i][0]
print(ass)


Measured memory_bytes: 54876
import collections,sys
def s():
 d=collections.deque()
 input()
 for e in sys.stdin:
  if'i'==e[0]:d.appendleft(e[7:-1])
  else:
   if' '==e[6]:
    m=e[7:-1]
    if m in d:d.remove(m)
   elif'i'==e[7]:d.popleft()
   else:d.pop()
 print(*d)
if'__main__'==__name__:s()



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

signed main() {
  int N, X;
  cin >> N >> X;
  vector<int> A(N);
  for( int i = 0; i < N; i++ ) cin >> A.at(i);
  sort(A.begin(), A.end());
  
  int ans = 0;
  for( int i = 0; i < N; i++ ){
    X -= A.at(i);
    if( X < 0 ){
      break;
    }else{
      ans++;
    }
  }
  if( X > 0 ) ans--;
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
T = input()

def fix(T,S):
    l = [[] for _ in range(26)]
    for k, c in enumerate([chr(ord("a") + i) for i in range(26)]):
        for i,t in enumerate(T):
            if t == c:
                l[k].append(i)

    for a in l:
        if len(a) <= 1:
            continue
        prop = S[a[0]]
        for i in a:
            if prop != S[i]:
                print("No")
                exit()

fix(T,S)
fix(S,T)

print("Yes")

Measured memory_bytes: 11628
#include<stdio.h>
#include<string.h>

int main()
{
	int n, i, j, ans = 1;
	
	scanf("%d", &n);
	
	char w[n][101], end;
	
	for(i = 0; i < n; i++){
		scanf("%s", w[i]);
	}
	
	end = w[0][strlen(w[0]) - 1];
	
	for(i = 0; i < n; i++){
		for(j = 0; j < i; j++){
			if(strcmp(w[i],w[j]) == 0){
				ans = 0;
				break;
			}
		}

		if(ans == 0){
			break;
		}
		
		if(i >= 1){
			if(w[i][0] != end){
				ans = 0;
				break;
			}else{
				end = w[i][strlen(w[i]) - 1];
			}
		}
	}
	
	if(ans == 1){
		printf("Yes");
	}else{
		printf("No");
	}
	

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
ll fact[200005];
#define eps 1e-9
#define INF 1e17
#define N 200005
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
 }
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n,k; cin>>n>>k;
        int b[n+1];
        memset(b,0,sizeof(b));
        while(k--){
            int d; cin>>d;
            while(d--){
                int x; cin>>x;
                b[x]++;
            }
        }
        int cnt=0;
        for(int i=1;i<=n;++i)if(b[i]==0)cnt++;
            cout<<cnt;
        return 0;
}


Measured memory_bytes: 3648
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

// ceil of a/b
inline int ceil(int a, int b) { return (a%b?a/b+1:a/b); }


signed main() {
	int x;
	std::cin >> x;
	int last = x%100;
	int count = x/100;
	print(count>=ceil(last,5));
	return 0;
}


Measured memory_bytes: 384
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=998244353;
constexpr int N=200000;

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

int D,c[26],s[200000][26],t[200000],T[200000],v,V,l[26];

int main(){
	scanf("%d",&D);
	for(int i=0;i<26;i++){
		scanf("%d",&c[i]);
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<26;j++){
			scanf("%d",&s[i][j]);
		}
	}
	for(int i=0;i<D;i++){
		pair<int,int>mx={-1,-1};
		for(int j=0;j<26;j++){
			mx=max(mx,{s[i][j],j});
		}
		t[i]=mx.second;
	}
	for(int i=0;i<26;i++){
		l[i]=-1;
	}
	for(int i=0;i<D;i++){
		l[t[i]]=i;
		v+=s[i][t[i]];
		for(int j=0;j<26;j++){
			v-=c[j]*(i-l[j]);
		}
	}
	for(int i=0;i<N;i++){
		for(int j=0;j<D;j++){
			if(xor128()%200){
				T[j]=xor128()%25;
			}
			else{
				T[j]=t[j];
			}
		}
		for(int j=0;j<26;j++){
			l[j]=-1;
		}
		V=0;
		for(int j=0;j<D;j++){
			V-=c[T[j]]*(j-l[T[j]]-1)*(j-l[T[j]])/2;
			l[T[j]]=j;
			V+=s[j][T[j]];
		}
		for(int j=0;j<26;j++){
			V-=c[j]*(D-l[j]-1)*(D-l[j])/2;
		}
		if(V>v){
			v=V;
			for(int j=0;j<D;j++){
				t[j]=T[j];
			}
		}
	}
	for(int i=0;i<D;i++){
		printf("%d\n",t[i]+1);
	}
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

li a[200200];
li b[200200];
li sum[200200];

map<li, li> cnt;

int main() {
    li n;
    cin >> n;
    li k;
    cin >> k;
    rin{
        cin >> a[i];
        b[i] = (a[i] + k - 1) % k;
    }
    sum[0] = 0;
    rin{
        sum[i + 1] = (sum[i] + b[i]) % k;
    }

    li res = 0;
    rep(i, n + 1) {
        res += cnt[sum[i]];
        cnt[sum[i]]++;
        if (i >= k - 1) {cnt[sum[i - k + 1]]--;}
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 17408