akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define Test ll t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define loopS(i,a,b,step) for(ll i=a;i<b;i+=step)
#define loopRS(i,a,b,step) for(ll i=a;i>=b;i-=step)
#define ull unsigned long long int
#define pll pair<ll,ll>
#define puu pair<ull, ull>
#define V vector
#define M map
#define UM unordered_map
#define mp(x,y) make_pair(x,y)
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define inf INT_MAX
#define S3(a,b,c) cin >> a >> b >> c
#define S2(a,b) cin >> a >> b
#define debug(x) cout << #x << " = " << x << endl;
using namespace std;

void input(ll n, ll arr[]) {
	rep(i, 0, n)cin >> arr[i];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cout.tie(NULL);
	ll n; cin >> n;
	ll arr[n + 1][4];
	rep(i, 1, n + 1) {
		rep(j, 1, 4) {
			cin >> arr[i][j];
		}
	}
	
	ll dp[n + 1][4];
	dp[1][1] = arr[1][1]; dp[1][2] = arr[1][2]; dp[1][3] = arr[1][3];
	
	rep(i, 2, n + 1) {

		dp[i][1] = arr[i][1] + max(dp[i - 1][2], dp[i - 1][3]);
		dp[i][2] = arr[i][2] + max(dp[i - 1][1], dp[i - 1][3]);
		dp[i][3] = arr[i][3] + max(dp[i - 1][1], dp[i - 1][2]);
		// debug(i);
		// debug(dp[i][1]); debug(dp[i][2]); debug(dp[i][3]);

	}
	cout << max(dp[n][1], max(dp[n][2], dp[n][3]));
}


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		int s[] = new int[100010];

		for (int i = 0; i < n; i++) {
			s[Integer.parseInt(str[i])]++;
		}

		int dec = 0;

		for (int i = 0; i < s.length; i++) {
			if (s[i] != 0) {
				if (s[i] % 2 == 0) {
					s[i] = 2;
				} else {
					s[i] = 1;
				}
			}
		}

		int one = 0;
		int two = 0;

		for (int i = 0; i < s.length; i++) {
			if (s[i] == 2) {
				two++;
			} else if (s[i] == 1) {
				one++;
			}
		}

		if (two % 2 != 0) {
			one--;
		}

		System.out.println(two + one);
	}

}

Measured memory_bytes: 45280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  set<int> st;
  rep(i,n){
    int m;
    cin >> m;
    st.insert(m);
  }
  int m=sz(st);
  if(m%2) cout << m << endl;
  else cout << m-1 << endl;


  return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstring>
#include <algorithm>
#include <list>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstdio>
#include <vector>

 
using namespace std;

typedef long long ll;
typedef long double ld;
#define L(ID) ((ID*2)+1)
#define R(ID) ((ID*2)+2)
#define M(L,R) ((L+R)/2)
#define forr(start,end) for(int i = start; i < end; i++)
#define gap ' '
 
const int MAXN = 2 * 1e5+5;

ll largest(ll a, ll b){
	return (a<b)?b:a;
}
ll smallest(ll a, ll b){
	if(a < b)return a;
	return b;
}
int main(){
	int n;
	cin >> n;
	ld ans = 0;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	ans = a[0];
	for(int i = 1; i < n; ++i){
		ans = (ans+a[i])/2;
	}
	cout << fixed << setprecision(10) << ans << endl;



    return 0;
}	

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

int main(){
    ll N, K;cin >> N >> K;
    while (N > abs(N - K))
    {
        ll u = N;
        N = min(u % K, K - (u % K));
    }
    cout << N << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;


ll dp[101][2][4];//0,1,2,3


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

	string S;
	ll K;
	cin >> S >> K;
	
		dp[0][0][0] = 1;
		dp[0][1][0] = 0;

	FOR(i, 1, S.length()+1) {
		int num = int(S[i-1] - '0');
		
		//dp[i-1][1][n] 既に未満フラグが経っているとき、
		FOR(j, 0, 4) {
			if (j > 0)dp[i][1][j] += dp[i - 1][1][j - 1] * 9;
			dp[i][1][j] += dp[i - 1][1][j];
		}
		//未満フラグが経っていないとき
		if (num == 0) {
			//未満フラグを立てないとき
			FOR(j, 0, 4)dp[i][0][j] += dp[i - 1][0][j];
		}
		else {
			//未満フラグたてない
			FOR(j, 1, 4)dp[i][0][j] += dp[i - 1][0][j - 1];
			//未満フラグ立てる
			FOR(j, 1, 4)dp[i][1][j] += dp[i - 1][0][j - 1] * (num-1);
			FOR(j, 0, 4)dp[i][1][j] += dp[i - 1][0][j];
		}


	}
	cout << dp[S.length()][0][K] + dp[S.length()][1][K] << endl;
	






	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		int len = s.length();
		final int m = 2019;
		long[] modCnt = new long[m];

		StringBuffer sb = new StringBuffer(s);
		s = sb.reverse().toString();

		long ans = 0;
		long x = 1;

		int tot=0;

		for (int i=1; i<=len; i++){
			modCnt[tot]++;
			tot += (s.charAt(i-1) - '0')  * x;
			tot %= m;
			ans += modCnt[tot];
			x = (x * 10) % m;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 32020
# -*- coding: utf-8 -*-

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

dp_a = [0 for _ in range(n)]

for i in range(n-1):
#    print("test i = "+str(i))
    if i == 0:
        dp_a[i] = b[i]
        dp_a[i+1] = b[i]
    else: #iが1以上なら
        if b[i] <= b[i-1]:
#            print(str(b[i])+"は"+str(b[i-1])+"以下")
            dp_a[i] = b[i]
            dp_a[i+1] = b[i]
        else:
#            print(str(b[i])+"は"+str(b[i-1])+"より大きい")
            dp_a[i+1] = b[i]
#print(dp_a)
print(sum(dp_a))

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for(int i = 0; i<N; i++){
    cin >> vec.at(i) ;
  }
  
  int c = 0;
  bool ans = false;
  while(true){
    for(int i = 0; i < N ;i++){
      if(vec.at(i) % 2 != 0){
        ans = true;
        break;
      }
      else vec.at(i) = vec.at(i)/2;
    }
    if(ans) break;
    c++;
  }
  
 cout << c << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)

int cnt=0;
void check(long long x,int n);

void dfs(long long x,int n){
    check(x,n);
    if(x<=n){
        dfs(x*10+3,n);
        dfs(x*10+5,n);
        dfs(x*10+7,n);
    }
    return;
}

void check(long long x,int n){
    if(x<=n){
        int a[10]={};
        long long b=x;
        while(b>0){
            a[b%10]++;
            b/=10;
        }
        if(a[3]*a[5]*a[7]>0){
            cnt++;
        }
        //cout<<x<<endl;
    }
}


int main(){
    int n;
    cin>>n;
    dfs(0,n);
    cout<<cnt<<endl;
    return 0;

}


Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>

using namespace std;

void print(string s, int a, int b) {
	cout << s.substr(a, b - a + 1) << endl;
}

string reverse(string s, int a, int b) {
	string t;
	t += s.substr(0, a);
	for (int i = 0; i < b - a + 1; i++) {
		t += s[b - i];
	}
	t = t + s.substr(b + 1, s.size() - b-1);
	return t;
}

string replace(string s,string p, int a, int b) {
	string t;
	t += s.substr(0, a);
	t = t + p;
	t = t + s.substr(b + 1, s.size() - b-1);
	return t;
}


int main() {
	string str;
	int q;
	string o[101];
	string r[101];
	int a[101], b[101];

	cin >> str >> q;
	for(int i=0;i<q;i++){
		cin >> o[i] >> a[i] >> b[i];
		if (o[i] == "replace") cin >> r[i];
	}

	for (int i = 0; i < q; i++) {
		if (o[i] == "replace") {
			str = replace(str, r[i], a[i], b[i]);
		}
		else if (o[i] == "reverse") {
			str = reverse(str, a[i], b[i]);
		}
		else {
			print(str, a[i], b[i]);
		}
	}
}

Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<vector>
using namespace std;
struct xy{int x,y;};
int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int bl[30][30]={{}};
  int bbl[30][30]={{}};
  int abl[30][30]={{}};
  int i,j,k;
  string str;
  for(i=0;i<h;i++){
    cin >> str;
    for(j=0;j<w;j++){
      if(str[j]=='.') bl[j][i]=0;
      else bl[j][i]=str[j]-'A'+1;
    }
  }
  int f=0;
  /*
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cout << bl[j][i];
    }
    cout << endl;
  }
  cout << endl;
  */
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      abl[j][i]=bl[j][i];
    }
  }
  
  int o=1;
  for(int a=0;a<w-1;a++){
    for(int c=0;c<h;c++){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	bl[j][i]=abl[j][i];
      }
    }

    //if(bl[a][c]==0||bl[a+1][c]==0) continue;
    bl[a][c]=abl[a+1][c];
    bl[a+1][c]=abl[a][c];
    for(j=0;j<w;j++){
      vector <int> vx;
      for(i=0;i<h;i++) if(bl[j][i]!=0) vx.push_back(bl[j][i]);
      int vs=vx.size();
      for(i=0;i<h-vs;i++) {
	bl[j][i]=0;
      }
      for(i=h-vs;i<h;i++) {
	bl[j][i]=vx[i+vs-h];
      }
      
    }
    /*
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	cout << bl[j][i];
      }
      cout << endl;
    }
    cout << "a" << endl;
    */
    f=0;
    while(f==0){
      f=1;
      vector <xy> v;
      xy bxy;
      for(i=0;i<h;i++){
	for(j=0;j<w;j++){
	  bbl[j][i]=bl[j][i];
	}
      }
      int l,b;
      for(i=0;i<h;i++){
	l=1;b=bbl[0][i];
	bxy.y=i;
	for(j=1;j<w;j++){
	  if(b==bbl[j][i]) l++;
	  else{
	    b=bbl[j][i];
	    if(l>=n) {
	      for(k=1;k<=l;k++){
		bxy.x=j-k;
		v.push_back(bxy);
	      }
	    }
	    l=1;
	  }
	  if(j==w-1){
	    if(l>=n) {
	      for(k=0;k<l;k++){
		bxy.x=j-k;
		v.push_back(bxy);
	      }
	    }
	  }
	}
      }
      
      for(j=0;j<w;j++){
	l=1;b=bbl[j][0];
	bxy.x=j;
	for(i=1;i<h;i++){
	  if(b==bbl[j][i]) l++;
	  else{
	    
	    if(l>=n) {
	      //if(b!=0) cout << l << endl;
	      for(k=1;k<=l;k++){
		bxy.y=i-k;
		v.push_back(bxy);
	      }
	    }
	    b=bbl[j][i];
	    l=1;
	  }
	  if(i==h-1){
	    if(l>=n) {
	      //if(b!=0) cout << l << endl;
	      for(k=0;k<l;k++){
		bxy.y=i-k;
		v.push_back(bxy);
	      }
	    }
	  }
	}
      }
      
      for(i=0;i<v.size();i++){
	if(bl[v[i].x][v[i].y]!=0) f=0;
	bl[v[i].x][v[i].y]=0;
      }
      
      
      for(j=0;j<w;j++){
	vector <int> vx;
	for(i=0;i<h;i++) if(bl[j][i]!=0) vx.push_back(bl[j][i]);
	int vs=vx.size();
	for(i=0;i<h-vs;i++) {
	  bl[j][i]=0;
	}
	for(i=h-vs;i<h;i++) {
	  bl[j][i]=vx[i+vs-h];
	}
	
      }
      
      /*
      for(i=0;i<h;i++){
	for(j=0;j<w;j++){
	  cout << bl[j][i];
	}
	cout << endl;
      }
      cout <<"e" <<  endl;
      */
    }
    int x=0;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	x+=bl[j][i];
      }
    }
    if(x==0) o=0;
  }
  }
  if(o==0) cout << "YES" << endl;
  else cout << "NO" << endl; 
  return 0;
}

Measured memory_bytes: 1264
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    static int dx[]={-1,0,1,0};
    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}


        
//        long L=sc.nextLong();
        int n=sc.nextInt();	
        int h[]=new int[n];
        int dp[]=new int[n];
        
        for (int i = 0; i < n; i++) {
        	h[i] = sc.nextInt();
		}
        dp[1]=abs(h[0]-h[1]);
        
        for (int i = 2; i < dp.length; i++) {
			dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),
					dp[i-2]+abs(h[i]-h[i-2]));
		}


        out.println(dp[n-1]);
        out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }


    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

class P {
    int id, d;
    P(int  id, int d) {
        this.id=id;
        this.d=d;
    }
}

//class P implements Comparable<P>{
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//    public int compareTo(P p){
//        return d-p.d; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 34320
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s,ans="yes";
	cin >> s;
	sort(s.begin(),s.end());
	for(int i=1;i<s.size();i++){
		if(s[i-1]==s[i])ans="no";
	}
	cout << ans << endl;
}

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

using namespace std;

void solve();

int main() {
#ifdef OFFLINE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

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

typedef pair<int, int> pii;

#define int long long

const int N = 100001;

vector<int> g[N];

int n, k;
int ans;

int dfs(int u, int par=-1) {
	int h = 1;
	for (int v: g[u])
		h = max(h, dfs(v, u) + 1);
	if (h == k && u != 0 && par != 0) {
		ans++;
		return 0;
	}
	return h;
}

void solve() {
	cin >> n >> k;
	
	forn(i, n) {
		int par; cin >> par; --par;
		if (i)
			g[par].push_back(i);
		else
			ans += (par != 0);
	}

	dfs(0);

	cout << ans << endl;
}


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

int main()
{

  int n,m ;
  cin >> n >> m  ;

  double a[n] ;
  double SUM = 0 ;
  for(int i=0;i<n;i++){
   cin >> a[i] ;
   SUM+=a[i] ;
  } 

  double lim = SUM/(4.0*m) ;

  sort(a,a+n,std::greater<double>()) ;

  bool flag = 1 ;
  for(int i=0;i<m;i++){
      if(a[i]>=lim){
       continue ;
      }else{
         flag = 0 ;
          break;
      }
  }

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

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define MAXN 100005
#define lint long long
#define trace(x) cout << #x << " = " << x << '\n'
using namespace std;
struct ii {
	int a, b;
	bool operator < (ii o) const { return tie(a, b) < tie(o.a, o.b); }
};
struct iii {
	int a, b, c;
	bool operator < (iii o) const { return tie(a, b, c) < tie(o.a, o.b, o.c); }
};
int TC, N, M, K, Q, x, y, z, ans;
lint mod(lint n) { return (n%MOD + MOD)%MOD; }
lint kali(lint a, lint b, lint c = 1, lint d = 1) { return mod(mod(a*b)*mod(c*d)); }

int tinggi[MAXN];
vector<int> antri, edge[MAXN];

void dfs(int now) {
	tinggi[now] = edge[now].size()+1;
	for (int i: edge[now]) dfs(i);
	antri.clear();
	for (int i: edge[now]) antri.push_back(tinggi[i]);
	assert(antri.size() == edge[now].size());
	sort(antri.begin(), antri.end());
	for (int i = 0; i < (int)antri.size(); i++) {
		tinggi[now] = max(tinggi[now], antri[i]+(int)antri.size()-i);
	}
}

int main() {
	#ifdef FAIRUZI10
	freopen("/home/fairuzi/Documents/CP/input.in", "r", stdin);
	#endif
	
	scanf("%d", &N);
	for (int i = 1; i < N; i++) {
		scanf("%d", &x);
		edge[x-1].push_back(i);
	}
	dfs(0);
	printf("%d\n", tinggi[0]-1);
	
	return 0;
}


Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
using ll = long long;
using namespace std;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }
//sort(a, a + N, greater<ll>())   // descend
//sort(a, a+N)                    //  ascend

/* 
void comb(vector<vector <ll> > &v) {
	ll mod=1000000007;
	rep (i,0,v.size()) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	rep (k,1,v.size()) {
		rep (j,1,k) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%mod;
		}
	}
}
/*main内でnCn~nC0 生成 **
vector<vector<ll> > v(n + 1, vector<ll>(n + 1, 0));
comb(v);
*/

int main() {
	ll n,c,k;
	cin>>n>>c>>k;
	ll t[110000];
	rep(i,0,n)cin>>t[i];
	sort(t,t+n);
	ll time = t[0];
	ll cnt =0;
	ll x=0;
	ll p=0;
	ll f=1;
	while(x<n){
		while(t[x+f]-t[p]<=k) f++;
		cnt++;
		p=p+min(c,f);
		x=p;
		f=1;
	}
	cout<<cnt;
}


Measured memory_bytes: 1024
use proconio::{input, fastout};
// use itertools::Itertools;

#[fastout]
fn main() {
  input!{
    s: String,
    t: String
  };
  let ans = if s[..] == t[0..t.len()-1] {
    "Yes"
  } else {
    "No"
  };
  println!("{}", ans);
}


Measured memory_bytes: 2168
WORDS = ['dream', 'dreamer', 'erase', 'eraser']
REVERSED_WORDS = [word[::-1] for word in WORDS]


def main(s):
    i = 0
    while i < len(s):
        for word in REVERSED_WORDS:
            if s[i:].startswith(word):
                i += len(word)
                break
        else:
            print('NO')
            break
    else:
        print('YES')


if __name__ == "__main__":
    main(input()[::-1])


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

int main() {
  int n,m,k;
  cin >> n >> m >> k;
  vector<int> a(n),b(m);
  for ( int i=0; i<n; i++ ) cin >> a[i];
  for ( int i=0; i<m; i++ ) cin >> b[i];
  int mia=1e9,mib=1e9;
  for ( int i=0; i<n; i++ ) mia=min(mia,a[i]);
  for ( int i=0; i<m; i++ ) mib=min(mib,b[i]);
  int ans=mia+mib;  
  for ( int i=0; i<k; i++ ) {
    int x,y,z;
    cin >> x >> y >> z;
    --x; --y;
    ans=min(ans,a[x]+b[y]-z);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4024
def main():
    abc = list(map(int, input().split()))

    abc_sort = sorted(abc)
    min_num, mid_num, max_num = abc_sort
    Count = 0
    while(max_num - min_num > 1):
        diff = max_num - min_num
        Count += diff//2
        abc_sort[0] += (diff//2) * 2
        abc_sort = sorted(abc_sort)
        max_num = abc_sort[2]
        min_num = abc_sort[0]

    if (abc_sort[2] - abc_sort[1] == 1):
        Count += 1
    elif (abc_sort[2]-abc_sort[1] == 0 and abc_sort[1] - abc_sort[0] == 1):
        Count += 2
    print(Count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9032
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>

using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	long long pat[100001];
	for (int i = 1; i <= n; i++) {
		int x = 0;
		int num;
		num = i;
		while (num < k) {
			num = num * 2;
			x++;
		}
		pat[i - 1] = pow(2, 20 - x);

		
	}
	long long sum;
	sum = 0;
	for (int i = 0; i < n; i++) {
		sum += pat[i];

	}
	double ans;
	ans = sum / (n*pow(2, 20));
	cout << std::setprecision(13) << ans << endl;

	return 0;
}

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

const long long MAX = 10000;
const long long MOD = 1000000007;

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(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    long long N, K;
    cin >> N >> K;

    for(long long i = 1; i <= K; i++)
    {
        COMinit();
        long long a = COM(N-K+1,i);
        COMinit();
        long long b = COM(K-1,i-1);
        cout << a*b%MOD << endl;
    }
    return 0;
}

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

/* #pragma */
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

/*alias*/
#define F first
#define S second

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

/* func */
int32_t GCD(int a,int b){return b?GCD(b,a%b):a;}
int64_t GCD(long long a, long long b){return b ? GCD(b, a%b) : a;}
int32_t LCM(int a, int b){return a * b / GCD(a, b);}
int64_t LCM(long long a, long long b){return a * b / GCD(a, b);}

/*struct*/
struct aaa {
	aaa() {
		cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);
	};
}aaaaaaa;

/* const */
constexpr int32_t INF = 1001001001;
constexpr int64_t LINF = 1001001001001001001ll;
constexpr int32_t MOD = 1e9 + 7; //10^9
constexpr int64_t EPS = 1e-9;
constexpr int32_t dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//constexpr int32_t dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
//Counterclockwise from the 6o'clock direction
//Take the x-axis downward and the y-axis right


//g++ -std=c++14 -Wall --pedantic-errors -o template template.cpp
//g++ -std=c++14 -Wall --pedantic-errors template.cpp
//chcp 65001

/*global*/



#define int int64_t
signed main()
{
	int mod = 2019;
	int l,r;cin >> l >> r;
	if(l == 0){
		cout << 0 << endl;
		return 0;
	}
	int a=INF;/*
	if(l <= r/2)
	for(int i = l; i < sqrt(r); ++i){
		for(int j = l+1; j <= sqrt(r)-sqrt(i); ++j){//-sqrt(i)
			a = min(a, i*j%mod);
		}
	}
	else{
		for(int i = l; i < r; ++i){
			for(int j = l+1; j <= r; ++r){
			a = min(a, i*j%mod);
			}
		}
	}*/
	if(r-l >= 10000){
		cout << 0 << endl;
		return 0;
	}
	for(int i = l; i < r; ++i){
		for(int j = i+1; j <= r; ++j){
			a = min(a, i*j%mod);
		}
	}

	cout << a << endl;	
}

Measured memory_bytes: 256
import itertools
N, M, Q = map(int,input().split())

cond_list = [list(map(int,input().split())) for i in range(Q)]

point_max=0
for i in itertools.combinations_with_replacement(range(1,M+1),N):
    point = 0
    for cond in cond_list:

        if (i[cond[1]-1]-i[cond[0]-1]) == cond[2]:

            point = point + cond[3]
    if point>point_max:
        point_max = point

print(point_max)

Measured memory_bytes: 67920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60;
ll ans = 0;

int main()
{
ll n , t ;
cin >> n >> t ;
vector<pair<ll,ll>> v;
vector<pair<double,ll>> k;
vector<ll> z;
rep(i,n){
  ll a , b ;
  cin >> a >> b ;
  v.emplace_back(a,b);
  if(a!=0)k.emplace_back((double)a/(b+1),i);
  else z.push_back(b);
}
sort(k.begin(),k.end());
reverse(k.begin(),k.end());
sort(z.begin(),z.end());
vector<vector<ll>> dp(30, vector<ll>(k.size()+1,INF) );
dp[0][0]=0;
rep(i,k.size()){
  rep(j,29){
    if(dp[j][i]==INF)continue;
    dp[j][i+1]=min(dp[j][i+1],dp[j][i]);
    if(dp[j][i+1]>t)dp[j][i+1]=t+1;
    dp[j+1][i+1]=min(dp[j+1][i+1],1+v[k[i].second].first*(1+dp[j][i])+v[k[i].second].second+dp[j][i]);
    if(dp[j+1][i+1]>t)dp[j+1][i+1]=t+1;
  }
}
rep(i,30){
  if(dp[i][k.size()]>t)continue;
  ll an=i;
  for(auto r:z){
    if(dp[i][k.size()]+1+r<=t){
      dp[i][k.size()]+=1+r;
      an++;
    }
    else break;
  }
  ans=max(ans,an);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 56668
import java.util.Scanner;

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

        if(A>=13)
            System.out.println(B);
        else
            if(A>=6 && A<=12){
            B=B>>1;
                System.out.println(B);
            }
            else{
                System.out.println(0);
            }

    }
}


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

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int b = 0;
	for(auto c : s) if(c == 'B') ++b;
	long long ans = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] != 'R') continue;
		for(int j = 0; j < n; ++j){
			if(s[j] != 'G') continue;
			ans += b;
			int x = i, y = j;
			if(x > y) swap(x, y);
			int d = y - x;
			if(d % 2 == 0 && s[x + d / 2] == 'B') --ans;
			if(x - d >= 0 && s[x - d] == 'B') --ans;
			if(y + d < n && s[y + d] == 'B') --ans;
		}
	}
	cout << ans << endl;
}

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

void PrintfArray(int a[], int n)
{
    for(int i = 0; i < n; i++)
    {
        if( i )
            cout << " ";
        cout << a[i];
    }
    cout << endl;
}

void insertionSort(int a[], int n)
{
    for(int i = 1; i < n; i++)
    {
        int temp = a[i];
        int j = i - 1;
        while(j >= 0 && temp < a[j]){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = temp;
        PrintfArray(a, n);
    }
}

int main() {
	int n;
	cin >> n;
	int* a = new int[n];
	for(int i = 0; i < n; i++)
	{
	    cin >> a[i];
	}
	
	PrintfArray(a, n);
	
	insertionSort(a, n);
	
	
	return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws Exception {

        // 入力データの準備
        Scanner scanner = new Scanner(System.in);
        String inputCountData = scanner.nextLine();
        String inputCheckNumberData = scanner.nextLine();
        scanner.close();

        // 入力された整数の個数を取得
        int count = Integer.parseInt(inputCountData);

        // 入力整数のチェック
        // int型への変換
        boolean checkFlag = true;
        if (count == 1) {
            int checkNumber = Integer.parseInt(inputCheckNumberData);
            if (checkNumber % 2 == 0) {
                if (checkNumber % 3 == 0 || checkNumber % 5 == 0) {
                    checkFlag = true;
                } else {
                    checkFlag = false;
                }
            }
        } else {
            ArrayList<Integer> checkNumberList = new ArrayList<>();
            String[] editedInputCheckNumberData = inputCheckNumberData.split(" ");
            for (int cnt = 0; cnt < editedInputCheckNumberData.length; cnt++) {
                int checkNumber = Integer.parseInt(editedInputCheckNumberData[cnt]);
                checkNumberList.add(checkNumber);
            }

            // 値のチェック
            for (int inputNumber : checkNumberList) {
                if (inputNumber % 2 == 0) {
                    if (inputNumber % 3 == 0 || inputNumber % 5 == 0) {
                        checkFlag = true;
                    } else {
                        checkFlag = false;
                        break;
                    }
                }
            }
        }

        // 判定結果の出力
        if (checkFlag) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }

    }

}

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

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2005;
int u[N], v[N], dep[N];
vector<int> G[N];

void dfs(int u, int fa)
{
	for (int v : G[u]) if (v != fa)
		dep[v] = dep[u] + 1, dfs(v, u);
}

int main()
{
	int n = read(), k = read();
	for (int i = 1; i < n; ++i)
	{
		u[i] = read();
		v[i] = read();
		G[u[i]].push_back(v[i]);
		G[v[i]].push_back(u[i]);
	}
	
	int ans = n;
	if (k & 1)
	{
		for (int i = 1; i < n; ++i)
		{
			dep[u[i]] = 0;
			dep[v[i]] = 0;
			dfs(u[i], v[i]);
			dfs(v[i], u[i]);
			
			int cnt = 0;
			for (int j = 1; j <= n; ++j)
				if (dep[j] > k / 2) ++cnt;
			ans = min(ans, cnt);
		}
	}
	else
	{
		for (int i = 1; i <= n; ++i)
		{
			dep[i] = 0;
			dfs(i, 0);
			
			int cnt = 0;
			for (int j = 1; j <= n; ++j)
				if (dep[j] > k / 2) ++cnt;
			ans = min(ans, cnt);
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}


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

int main() {
    int64_t X, K, D;
    cin >> X >> K >> D;

    if (X < 0) {
        X = -X;
    }

    if (X / D > K) {
        if (D * K >= 0) {
            cout << X - D * K << endl;
        } else {
            int A;
            A = X / D - K;
            cout << D * A + X % D << endl;
        }
        return 0;
    }

    int64_t P;
    P = K - (X / D);
    if (P % 2 == 0) {
        cout << X - D * (K - P) << endl;
    } else {
        cout << - (X - D * (K - P + 1)) << endl;
    }


}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll N;
ll v[100000 + 10];
bool diffSign(ll a, ll b) {
  if (a < 0 && b > 0) return true;
  if (a > 0 && b < 0) return true;
  return false;
}

ll calc() {
  ll r1 = 0;
  ll psum = v[0];
  for (int i = 1; i < N; ++i) {
    if (diffSign(psum, psum + v[i])) {
      psum += v[i];
    } else {
      if (psum > 0) {
        r1 += (psum + v[i] + 1);
        psum = -1;
      } else {
        r1 += (1 - psum - v[i]);
        psum = 1;
      }
    }
  }

  return r1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> N;
  for (int i = 0; i < N; ++i) cin >> v[i];
  ll ret = 1LL << 62;

  const ll a0 = v[0];
  if (a0 != 0) {
    ret = min(ret, calc());
  }

  v[0] = 1;
  ret = min(ret, abs(a0 - v[0]) + calc());

  v[0] = -1;
  ret = min(ret, abs(a0 - v[0]) + calc());

  cout << ret << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;

  scanf("%d", &N);

  int ans = 0, cur = 1;

  for (int i=0; i<N; i++) {
    int A;
    scanf("%d", &A);
    ans += A != cur;
    cur += A == cur;
  }

  if (ans == N)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
d = defaultdict(list)
n, m = map(int, input().split())
l = [0]*m
for i in range(m):
  p, y = map(int, input().split())
  d[p].append((y, i))
for p, b in d.items():
  b.sort()
  for i in range(len(b)):
    s, t = b[i]
    l[t] = "0"*(6-len(str(p))) + str(p) + "0"*(6-len(str(i+1))) + str(i+1)
print(*l, sep="\n")

Measured memory_bytes: 46396
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define PI acos(-1)
#define eps 1e-10
#define mem(x) memset(x,0,sizeof(x))
#define _for(x,y,z) for(int (x)=(y);(x)<=(z);(x)++)
#define __for(x,y,z) for(int (x)=(y);(x)>=(z);(x)--)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

const int INF=0x3f3f3f3f;
const int MAX=1e5+5;
const int MOD=1e9+7;

ll x,y;
 

int main(){
    std::ios::sync_with_stdio(false);
    cin>>x>>y;
    if(x%y==0){
        cout<<-1<<endl;
        return 0;
    }
    cout<<x<<endl;
}





















Measured memory_bytes: 256
#pragma GCC optimize("O3", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

signed main() {
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9) {
		cout << -1 << endl;
	}
	else {
		cout << (a * b) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
#define lo long
const int lmax=1999999999;
const long long lmx=1999999999999999999;
int A,B;
int a,b,c;
int n,p[100003];
int main(){std::ios::sync_with_stdio(false);
cin>>n;
cin>>A>>B;
for(int i=0;i<n;i++){
	cin>>p[i];
}

for(int i=0;i<n;i++){
	if(p[i]<=A)a++;
	if(p[i]>=A+1&&p[i]<=B)b++;
	if(p[i]>=B+1)c++;
}
cout<<min(a,min(b,c))<<endl;
}
/*

                   *         *
                  * *       * *
                 *   *     *   *
                *     *   *     *
               *       * *       *
               *        *        *
                *               *
                 *             *
                  *           *
                   *         *
                    *       *
                     *     *
                      *   *
                       * *
                        *



*/





Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))

sort_p = sorted(p, key=lambda x: x)

counter = 0
for i in range(len(sort_p)):
    if sort_p[i] != p[i]:
        counter += 1
    if counter > 2:
        print("NO")
        exit()
if counter == 2 or counter == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>

inline void read(int &x)
{
	char c=x=0;
	for(c=getchar();!isdigit(c);c=getchar());
	for(;isdigit(c);c=getchar())x=x*10+(c^48);
}

namespace o_o
{
	const int N=1010,M=200100;

	bool g[N][N],ans[N][N];
	int f0[N],f1[N];

	std::vector<int>G[N];

	void Dfs(int p,int h,int *f)
	{
		if(f[p])return;f[p]=h;
		for(int i=0;i<(int)G[p].size();i++)
			Dfs(G[p][i],h,f);
	}

	int n,m;

	inline void work(int p)
	{
		memset(f0,0,sizeof(f0)),memset(f1,0,sizeof(f1));
		f0[p]=f1[p]=2333;

		for(int i=0;i<(int)G[p].size();i++)
			Dfs(G[p][i],G[p][i],f0);
		for(int i=G[p].size()-1;~i;i--)
			Dfs(G[p][i],G[p][i],f1);

		for(int i=1;i<=n;i++)
			ans[p][i]=f0[i]!=f1[i],g[p][i]=(f0[i] || f1[i]);
	}

	int E[M][2];

	void solve()
	{
		read(n),read(m);
		for(int i=1,u,v;i<=m;i++)
			read(u),read(v),E[i][0]=u,E[i][1]=v,G[u].push_back(v);

		for(int p=1;p<=n;p++)work(p);

		for(int i=1;i<=m;i++)
		{
			int u=E[i][0],v=E[i][1];
			if(g[v][u]^ans[u][v])printf("diff\n");
			else printf("same\n");
		}
	}
}

int main()
{
	o_o::solve();
	return 0;
}


Measured memory_bytes: 6400
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return [LIST() for _ in range(n)]


# 昇順列の巡回
def ascending(N, M):
    # 長さN, 値0からM-1まで
    A = [0] * N
    yield A
    while True:
        # Mより小さい最後の桁
        k = None
        for i in reversed(range(N)):
            if A[i] < M - 1:
                k = i
                break
        if k is not None:
            A[k] += 1
            for j in range(k + 1, N):
                A[j] = A[k]
        else:
            return
        yield A


INF = float("inf")
MOD = 10**9 + 7


def main():
    n, m, q = MAP()
    abcd = ZIP(q)

    def point(A):
        tot = 0
        for a, b, c, d in abcd:
            if A[b - 1] - A[a - 1] == c:
                tot += d
        return tot

    # 昇順列を巡回する
    ans = 0
    for a in ascending(n, m):         # O(N)
        p = point(a)
        # print(a)
        if ans <= p:
            ans = p
    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 75308
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  for (int i = 0; i < s.size() - 1; i++)
  {
    if (i != s.size() - 2)
    {
      if (s[i] == s[i + 2])
      {
        cout << i + 1 << " " << i + 3 << endl;
        return 0;
      }
    }
    if (s[i] == s[i + 1])
    {
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

typedef pair<double, double> pd;
typedef vector<pd> vpd;


#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> t chmax(t&a,u b){if(a<b)a=b; return a;};
template<class t, class u> t chmin(t&a,u b){if(a>b)a=b; return a;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  IN(N);
  vll S(1<<N);
  REP(i,1<<N) IN(S[i]);
  sort(ALL(S));
  reverse(ALL(S));

  vb flags(1<<N, false);
  flags[0] = true;

  queue<ll> que;

  REP(i,N){
    REP(j,1<<N){
      if(!flags[j]){
        if(que.empty()) continue;
        if(que.front()>S[j]){
          flags[j] = true;
          que.pop();
        }
      }else{
        que.push(S[j]);
      }
    }
    //vec_print(flags);
  }

  REP(i,1<<N){
    if(!flags[i]){
      OUT("No");
      return 0;
    }
  }

  OUT("Yes");

  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int n;
int dfs(long long s)
{
  if(s>n)return 0;
  long long  t=s;
  map<int,int>a;
  while(t>0)
  {
    a[t%10]++;
    t/=10;
  }
  int ans;
  if(a[3]==0 ||a[7]==0 || a[5] ==0)ans=0;
  else ans=1;
  vector<int>b{3,7,5};
  for(auto x:b)
    ans+=dfs(s*10+x);
  return ans;
}
  
int main()
{
  
  cin>>n;
  cout<<dfs(0);
  return 0;
}

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

int main() {
	int a,b,i,sum=0;
	int c[10000];
	while(1){
		cin >> a >> b;
		if(a==0 && b==0) break;
		for(i=0;i<a;i++){
			cin >> c[i];
			sum+=c[i];
		}
		sort(c,c+a);
		reverse(c,c+a);
		for(i=b-1;i<a;i+=b){
			sum-=c[i];
		}
		cout << sum << endl;
		sum=0;
	}
	

	return 0;
}

Measured memory_bytes: 2984
class priorityQueue {
  constructor() {
    this.keys = [];
    Number.prototype.parentIdx = function() { return Math.ceil(this/2 - 1); };
    Number.prototype.leftIdx = function() { return this * 2 + 1; };
    Number.prototype.rightIdx = function() { return this * 2 + 2; };
  }

  insert(key) { this.heapIncrease(this.keys.push(key) - 1); }

  heapIncrease(idx) {
    const keys = this.keys;
    for (let i=idx, p=idx.parentIdx(); i > 0 && keys[i] > keys[p]; i=p, p=i.parentIdx()) {
      keys[p] = [keys[i], keys[i] = keys[p]][0];
    }
  }

  extract() {
    const res = this.keys[0];
    this.keys[0] = this.keys.pop();
    this.maxHeapify(0);
    return res;
  }

  maxHeapify(idx) {
    const n = this.keys.length;
    const innerMaxHeapify = (i) => {
      let left, right, largest = i;
      left = i.leftIdx();
      right = i.rightIdx();
      if (left < n && Number(this.keys[left]) > Number(this.keys[largest])) largest = left;
      if (right < n && Number(this.keys[right]) > Number(this.keys[largest])) largest = right;
      if (largest != i) {
        this.keys[largest] = [this.keys[i], this.keys[i] = this.keys[largest]][0];
        innerMaxHeapify(largest);
      }
    };
    innerMaxHeapify(idx);
  }
}

(function main() {
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  lines.pop();
  const queue = new priorityQueue();
  let str = '';
  lines.forEach(function(cmd) {
    switch(cmd.charAt(0)) {
      case 'i': queue.insert(Number(cmd.split(' ')[1])); break;
      case 'e': str += `${queue.extract()|0}\n`; break;
    }
  });
  process.stdout.write(str);
})();




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

int main() {
 int a, x1, x2, x3, y;
 cin >> a;
 x1 = a/100;
 x2 = (a-x1*100)/10;
 x3 = a-x1*100-x2*10;
 y = x1+x2+x3;
 cout << y << endl;
}

Measured memory_bytes: 256
l=["SUN","MON","TUE","WED","THU","FRI","SAT"]
l=l+l
#print(l)
s=input()
id1=-1
for i in range(len(l)):
  if l[i]==s:
    id1=i
    break
id2=-1
for i in range(id1+1,len(l)):
  if l[i]=="SUN":
    id2=i
    break
print(id2-id1)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    
    int sin, h , m , s , remain;
    
    
    cin >> sin;
    
    h = sin / 3600;
    remain = sin % 3600;
    m = remain / 60;
    remain = remain % 60;
    s = remain;
    
    cout << h << ":" << m << ":" << s << endl;
    
 
   
   return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define int long long
int N, Q;
vector<vector<int> > G;
vector<int> ans;

void dfs(int start, int ago){
    for(int i = 0; i < G[start].size(); i++){
        int next = G[start][i];
        if(next == ago) continue;
        ans[next] += ans[start];
        dfs(next, start);
    }
}

signed main(){
    cin >> N >> Q;
    G.resize(N);
    for(int i = 0; i < N - 1; i++){
        int a, b; cin >>a >> b;
        G[a - 1].push_back(b - 1), G[b - 1].push_back(a - 1);
    }
    ans.resize(N, 0);
    for(int i = 0; i < Q; i++){
        int p, x; cin >> p >> x;
        ans[p - 1] += x;
    }
    dfs(0, -1);
    for(int i = 0; i < N; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 24576
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)


int main() {

int S,N; cin >> S >> N ;

if(S<=N) cout << "unsafe" << endl;

else cout << "safe" << endl;

return 0;
}

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

using namespace std;
using ll = long long;

template<class T> ostream& operator<<(ostream& os, const vector<T> arr){ for(int i = 0; i < (int)arr.size(); i++)cout << arr[i] << (i == (int)arr.size() -1 ? "" : " "); return os;}

int main()
{
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        int t; cin >> t;
        a[t - 1] = i + 1;
    }
    cout << a << endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    vector<int> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    if(v[0] != 5 || v[1] != 5 || v[2] != 7) return cout << "NO\n", 0;
    return cout << "YES\n", 0;
    return 0;  
}

Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main(){
	int n;
	string a;
	string u;
	string word;
	string answer = "NO";
	int count1 = 0;
	int count2 = 0;
	bool flag = 1;

	cin >> n;

	for(int i = 0; i< n; i++){
		cin >> word;

		if(word == "A"){
			count1++;
		}else{
			count2++;

			if(count1 == count2){
				answer = "YES";
			}else if(count1 < count2){
				flag = 0;
			}else{}
		}
	}

	if(flag == 0 || count1 > count2){
		cout << "NO" << endl;
	}else{
		cout << answer << endl;
	}
}

Measured memory_bytes: 3204