akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <chrono>
#include<math.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std::chrono;
using namespace std;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// declaration: ordered_set os;  methods->  1. *os.find_by_order(x)   2. os.order_of_key(k) ->return int

#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<ll,ll>
#define prr pair<pr,ll>
#define ll long long int
#define ld long double
const ll mod=1e9+7;
const int N=2e5+5;
void solve(){
    string s,t;
    cin>>s>>t;
    int a=0;
    fr(i,0,s.length())
    a+=(s[i]!=t[i]);
    cout<<a;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
//    build();
    int t=1;
//    cin>>t;
    while(t--)
    solve();

}


Measured memory_bytes: 3804
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pi(n) prllf("%d",n)
#define pl(n) prllf("%d",n)
using namespace std;

int main(){
  int a,b,c,d;
  cin >>a  >> b >> c>> d;
  if(abs(a-c)<=d)
    cout << "Yes" << endl;
  else{
    if(abs(a-b)<=d && abs(c-b)<=d)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def fip(x):
    return x*x*x*x*x

x = int(input())
divisors = []
i = 1
while i*i<=x:
    if x%i == 0:
        divisors.append(i)
        divisors.append(round(x/i))
    i+=1
for d in divisors:
    if fip(d)-fip(0) == x:
        print(d,0)
        break
    end = 1
    while fip(end)-fip(end-d)<=x:
        end*=2
    start = round(end/2)
    if end == 1:
        if fip(1)-fip(1-d) == x:
            print(1,1-d)
            break
    elif fip(end)-fip(end-d)==x:
        print(end,end-d)
        break
    answer = -1
    found = False
    while(start<=end and not found):
        mid = (start+end)//2
        if fip(mid)-fip(mid-d) == x:
            answer = mid
            found = True
        else:
            if fip(mid)-fip(mid-d)>x:
                end = mid-1
            else:
                start = mid+1
    if answer!=-1:
        print(answer,answer-d)
        break
    start = 0
    end = round((x/2)**(1/5))
    found = False
    while(start<=end and not found and start<=d):
        if fip(start)+fip(d-start) == x:
            answer = start
            found = True
        start+=1
    if found == True:
        print(answer,answer-d)
        break
    


Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;

ll dfs(ll s){
  if(s>n){
    return 0;
  }
  ll t=s,res=0;
  vector<ll> a(3),c(3);
  c[0]=3;
  c[1]=5;
  c[2]=7;
  bool b=true;
  while(t&&b){
    b=true;
    if(t%10==3){
      a[0]++;
    }
    if(t%10==5){
      a[1]++;
    }
    if(t%10==7){
      a[2]++;
    }
    if(a[0]>0&&a[1]>0&&a[2]>0){
      res++;
      b=false;
    }
    t/=10;
  }
  for(int i=0;i<3;i++){
    res+=dfs(10*s+c[i]);
  }
  return res;
}

int main(){
  cin >> n;
  if(n<=356){
    cout << 0 << endl;
  }
  else{
    cout << dfs(3)+dfs(5)+dfs(7) << endl;
  }
}
  

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

ans = []
for n in range(N-1):
    ansA = 0
    ansB = 0
    for i in range(N):
        if i > n:
            ansB += S[i]
        else:
            ansA += S[i]
    ans.append(abs(ansA - ansB)) 

print(min(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int64_t> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	int64_t ans = 0;
	int64_t M = A.at(0);
	for (int i = 1; i < N; i++) {
		if (M > A.at(i)) {
			ans = ans + (M - A.at(i));
		} else {
			M = A.at(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4760
N = int(input())
A = list(map(int, input().split()))

G = {i:[] for i in range(1, N + 1)}

res = 0

for i, a in enumerate(A, 1):
    if i in G[a]:
        res += 1

    G[a].append(i)
    G[i].append(a)

print(res)


Measured memory_bytes: 34868
#include<iostream>
 using namespace std;
 
 int main()
 {
 	int y, n;
 	cin >> y >> n;
 	if(y>=13){
 		n=n;
	 }
	else if(y<=5){
		n=0;
	}
	else{
		n=n/2;
	}
	cout << n;
	return 0;
 }

Measured memory_bytes: 256
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
//#define int long long
using namespace std;
const int N=1e6+10;
int n,a[N],cnt[N],gd,ok;
signed main(){
	cin>>n; gd=0;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]); gd=__gcd(gd,a[i]);
		for(int j=2;j*j<=a[i];j++) if(a[i]%j==0){
			while(a[i]%j==0) a[i]/=j;
			if(cnt[j]) ok=1;
			cnt[j]++;
		}
		if(a[i]>1){
			if(cnt[a[i]]) ok=1;
			cnt[a[i]]++;
		}
	}
	if(ok) puts(gd==1?"setwise coprime":"not coprime");
	else puts("pairwise coprime");
	return 0;
}


Measured memory_bytes: 11344
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    if(s[0]=='9' || s[1]=='9')
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;

    return 0;
}


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

int main(){

int n; cin >> n;
int x;
for(int i=1;i<=n;i++){
	if(i%3==0){
		cout << " " << i;
	}
	else{
		int x=i;
		while(x){
			if(x%10==3){
				cout << " " << i;
				break;
			}
			x /=10;
		}
	}
	}
	cout << endl;
}

Measured memory_bytes: 3076
w,h,s,t,f,g;m[123][102];c,d,x,y,i,j;C(x,y){m[x][y]-c||(m[x][y]=-1,x>1&&C(x-1,y),x<w&&C(x+1,y),y>1&&C(x,y-1),y<h&&C(x,y+1));}main(n){for(;scanf("%d%d%d%d%d%d%d",&w,&h,&s,&t,&f,&g,&n),w;c=m[s][t],C(s,t),puts(~m[f][g]?"NG":"OK"))for(memset(m,0,5e4);n--;)for(scanf("%d%d%d%d",&c,&d,&x,&y),i=4-d*2;i--;)for(j=2+d*2;j--;)m[x+i][y+j]=c;exit(0);}

Measured memory_bytes: 0
#include <stdio.h>

using namespace std;

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

const int MAX_H = 50;
const int MAX_W = 50;
char s[MAX_H][MAX_W + 1];

bool test(int H, int W) {
    REP(i, H) {
        REP(j, W) {
            if (s[i][j] == '#') {
                if ((i - 1) >= 0 && s[i - 1][j] == '#') {
                    continue;
                }
                if ((i + 1) < H && s[i + 1][j] == '#') {
                    continue;
                }
                if ((j - 1) >= 0 && s[i][j - 1] == '#') {
                    continue;
                }
                if ((j + 1) < W && s[i][j + 1] == '#') {
                    continue;
                }
                return false;
            }
        }
    }

    return true;
}

int main() {
    int H, W;
    scanf("%d %d", &H, &W);

    REP(i, H) {
        scanf("%s", s[i]);
    }

    if (test(H, W)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <initializer_list>
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <cassert>
//#include <unordered_map>
//#include <unordered_set>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define eps 1e-8
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define DE(val) cout<<#val<<": "<<val<<endl;

const int dx44[5] = { 0,-1,-1,1,1 };
const int dy44[5] = { 0,-1,1,-1,1 };

const int dx4[5] = { 0,-1,0,1,0 };
const int dy4[5] = { 0,0,1,0,-1 };
const int dx8[9] = { 0,-1,0,1,0,1,1,-1,-1 };
const int dy8[9] = { 0,0,1,0,-1,1,-1,1,-1 };
const int maxn = 1e6 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b, ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a, ll b) { if (a == 0) { return b; } else { return gcd(b%a, a); } }
void YES() { puts("YES"); exit(0); }
void Yes() { puts("Yes");}// exit(0); }
void NO() { puts("NO"); exit(0); }
void No() { puts("No");}// exit(0); }
void one() { puts("-1"); exit(0); }

int n;
map<int,int>hax;
void solve()
{
	sa(n);
	repp(i,1,n)
	{
		int x;
		sa(x);
		hax[x]++;
	}
	int q;
	sa(q);
	while(q--)
	{
		int x;
		sa(x);
		hax[x]--;
		if(hax[x]<0)
		{
			puts("NO");
			return;
		}
	}
	puts("YES");
}

int main()
{


	solve();
	// system("pause");
	return 0;
}


Measured memory_bytes: 9600
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


N = int(input())
if N == 1:
    print(0)
    exit()
L = factorization(N)
res = 0
for l in L:
    a = int(l[1])
    count = 1
    while True:
        if a >= count:
            a -= count
            res += 1
            count += 1
        else:
            break
print(res)


Measured memory_bytes: 63452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[2001];
ll af[2001],fr[2001];
int main() {
	ll n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	for(int i=0;i<n;i++){
		ll now=a[i];
		for(int j=0;j<n;j++){
			if(i==j){
				continue;
			}
			ll next=a[j];
			if(now>next){
				if(i<j){
				af[i]++;
				}
				else{
					fr[i]++;
				}
			}
		}
	}
	ll sekiaf=k*(k+1)/2;
	sekiaf%=inf;
	ll sekifr=(k-1)*(k)/2;
	sekifr%=inf;
	ll ans=0;
	for(int i=0;i<n;i++){
		ans+=af[i]*sekiaf+fr[i]*sekifr;
		ans%=inf;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

const int MAX_N = 5e3 + 200, DOM = 2500, mod = 1e9 + 7;

int mp[MAX_N][MAX_N], n, xi[MAX_N * 100], yi[MAX_N * 100], fac[MAX_N * MAX_N];

int quick_pow(int bas, int tim)
{
    int ret = 1;
    while (tim)
    {
        if (tim & 1)
            ret = 1LL * ret * bas % mod;
        bas = 1LL * bas * bas % mod;
        tim >>= 1;
    }
    return ret;
}

int main()
{
    scanf("%d", &n);
    for (int i = fac[0] = 1; i < MAX_N * MAX_N; i++)
        fac[i] = 1LL * fac[i - 1] * i % mod;
    for (int i = 1; i <= n; i++)
    {
        scanf("%d%d", &xi[i], &yi[i]);
        mp[DOM - xi[i]][DOM - yi[i]]++;
    }
    for (int i = 1; i <= (DOM << 1); i++)
        for (int j = 1; j <= (DOM << 1); j++)
            mp[i][j] = (1LL * mp[i][j] + mp[i - 1][j] + mp[i][j - 1]) % mod;
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        int pans = mp[xi[i] + DOM][yi[i] + DOM];
        // get oneself outta here;
        int myself = 1LL * fac[(xi[i] << 1) + (yi[i] << 1)] * quick_pow(fac[xi[i] << 1], mod - 2) % mod * quick_pow(fac[yi[i] << 1], mod - 2) % mod;
        ans = (1LL * ans + (pans + mod - myself) % mod) % mod;
    }
    printf("%lld\n", 1LL * ans * quick_pow(2, mod - 2) % mod);
    return 0;
}

Measured memory_bytes: 213248
using System;

class plogram
{
    static void Main()
    {

        string[] array = Console.ReadLine().Split(' ');

        int N = int.Parse(array[0]);
        int K = int.Parse(array[1]);

        string S = Console.ReadLine();
        string str = S.Substring(0, K - 1) + S.Substring(K - 1, 1).ToLower() + S.Substring(K);

        Console.WriteLine(str);
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N, M; cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int a[n+2];
    a[0]=a[n+1]=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int l[n+2],r[n+2];
    l[0]=r[n+1]=0;
    for(int i=1;i<=n;i++){
        l[i]=max(l[i-1],a[i]);
    }
    for(int i=n;i>=1;i--){
        r[i]=max(r[i+1],a[i]);
    }
    for(int i=1;i<=n;i++){
        cout<<max(l[i-1],r[i+1])<<endl;
    }
}


Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main(void){
  int n,i,a,b;
  ll k;
  vector<P> op;
  
  cin >> n >> k;
  for (i=0;i<n;i++){
    cin >> a >> b;
    op.push_back(P(a,b));
  }
  
  sort(op.begin(),op.end());
  
  for (i=0;i<n;i++){
    if (k<=op[i].second) break;
    k-=op[i].second;
  }
  
  cout << op[i].first << endl;
  
  return 0;
}

Measured memory_bytes: 1400
//
//  main.cpp
//  D - Caracal vs Monster
//
//  Created by Hashizo on 2020/01/26.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {
	ll ans = 0;

	ll h;
	cin >> h;

	ll pp  = 0;
	ll POW = 0;
	
	while(1) {
		POW = pow(2, pp);
		if (h < POW) {
			break;
		}
		
		ans += POW;
		
		pp++;
	}
	
	
	
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int field[20][20];
int dp[20][20];

int n, m;

bool isIn(int x, int y){
    return 0 <= x && x < n && 0 <= y && y < m;
}

int main(){
    while(cin >> m >> n, n+m){
        for(int i=0; i < n; i++) for(int j=0; j< m; j++){cin >> field[i][j];}
        for(int i=0; i< 20; i++) for(int j=0; j< 20; j++) dp[i][j] = 0;
        for(int i=0; i < m; i++) dp[0][i] = 1;
        for(int i=0; i < n-1; i++){
            for(int j=0; j < m; j++){
                if(field[i][j] == 0){
                    for(int k=-1; k <= 1; k++){
                        if(isIn(i+1, j+k) && !(k != 0 && field[i+1][j+k] == 2)){
                            dp[i+1][j+k] += dp[i][j];
                        }
                    }
                }
                else if(field[i][j] == 2) dp[i+2][j] += dp[i][j];
            }
        }
        for(int i=0; i< m; i++) if(field[n-1][i] != 1)dp[n][i] += dp[n-1][i];
        long long count = 0;
        for(int i=0; i< m; i++) count += dp[n][i];
        cout << count << endl;
    }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(register int i=0;i<l;i++)
        if(s[i]=='C')
            for(register int j=i+1;j<l;j++)
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n, k;
	cin >> n >> k;
	cout << ((n%k == 0) ? 0 : 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;
typedef vector<vector<int>> mat;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	ll n,range,damage,x,h;

	//cordenada y cant de bombas necesarias para h=0
	vector<pair<int,int>> monster;
	cin>>n>>range>>damage;

	for(int i=0;i<n;i++)
	{
		cin>>x>>h;
		h=(h+damage-1)/	damage ;
		monster.emplace_back(x,h);
	}
	sort(monster.begin(),monster.end());

	ll ans=0;
	ll currentDamage=0;
	vector<ll> changes(n+1);
	for(int i=0;i<n;i++)
	{
		currentDamage+=changes[i];
		ll monsterh=monster[i].second - currentDamage;
		if(monsterh<=0)continue;
		//Encontrar el ult monst afectado
		int l=i;
		int r=n;
		while(l+1<r)
		{
			int m=(l+r)>>1;
			if(monster[m].first<=monster[i].first+2LL*range)
				l=m;
			else r=m;
		}
		changes[l+1]-=monsterh;
		currentDamage+=monsterh;
		ans+=monsterh;
	}

	cout<<ans<<endl;


	return 0;
}

Measured memory_bytes: 3568
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i).sort
ans = Array.new(a[-1]+1, false)
h = Array.new(a[-1]+1, 0)

a.each do |i|
    ans[i] = true
    h[i] += 1
end

a.each do |i|
    next unless ans[i]
    ans[i] = false if h[i] > 1
   
    (i*2).step(a[-1], i) do |j|
      ans[j] = false
    end
end

puts ans.count(true)

Measured memory_bytes: 47964
#include<stdio.h>
#include<iostream>
using namespace std;

int main(){
	
	double c, r,a1, a2;
	c = 3.141592653589;
	cin >> r;
	a1 = r*r*c;
	printf("%.6lf\n", a1);
	a2 = 2 * r*c;
	printf("%.6lf\n", a2);

	

	return 0;
}

Measured memory_bytes: 3204
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int A=sc.nextInt();
		int B=sc.nextInt();
		String s=sc.next();
		int f=0;
		int g=0;
		for(int i=0; i<N; i++) {
			if(s.charAt(i)=='c') {
				pl("No");
			}
			else if(s.charAt(i)=='a') {
				if(g<A+B) {
					pl("Yes");
					g++;
				}
				else {
					pl("No");
				}
			}
			else if(s.charAt(i)=='b') {
				if(g<A+B && f<B) {
					pl("Yes");
					g++;
					f++;
				}
				else {
					pl("No");
				}
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}

Measured memory_bytes: 36132
#include <stdio.h>
#include <stdlib.h>
typedef struct a{
    int queue[100];
    int a,b;
}Queue;

Queue* init(){
    Queue* k = (Queue*)malloc(sizeof(Queue));
    k->a=0;k->b=0;
    return k;
}

void enqueue(Queue* q,int n){
    q->queue[q->b]=n;
    q->b++;
}

int dequeue(Queue* q){
   int n=q->queue[q->a];
   q->a++;
   return n;
}

int main(void){
    int n,i,j,u,k,l,time=0;
    int a[100][100];
    int dist[100];
    Queue* q;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        dist[i]=-1;
        for(j=0;j<n;j++){
            a[i][j] = 0;
        }
    }
    for(i=0;i<n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
        for(j=0;j<k;j++){
            scanf("%d",&l);
            a[u-1][l-1] = 1;
        }
    }
    q = init();
    enqueue(q,0);
    dist[0]=0;
    while(q->a < q->b){
        u = dequeue(q);
        for(i=0;i<n;i++){
            if(a[u][i]==1&&dist[i]==-1){
                enqueue(q,i);
                dist[i]=dist[u]+1;
            }
        }
    }
    
    for(i=0;i<n;i++){
        printf("%d %d\n",i+1,dist[i]);
    }
}


Measured memory_bytes: 2092
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<int>>
constexpr auto mod = 1000000007;


//2のn乗を求めるよ！！！
int ni(int n) {
	if (n == 0)return 1;
	int x = ni(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;
}

//フィボナッチ数列のx番目を求めるよ！
int f(int x,vector<int> s) {
	if (x == 0)return 0;
	if (x == 1)return 1;
	if (s[x] != 0)return s[x];
	s[x] = f(x - 1,s) + f(x - 2,s);
	return s[x];
}

//aとｂの最大公約数を求めるよ！
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}



// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b,ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}

//m進数のn桁を全列挙やで
void dfs(int m, int n) {

	stack<string> st;
	st.push("");
	while (!st.empty()) {
		string now = st.top();
		st.pop();
		if (now.size() == n) {
			cout << now << endl;
		}
		else {
			for (int i = m-1; i >= 0; i--) {
				string next = now + to_string(i);
				st.push(next);
			}
		}
	}
}

int  main() {
	int n;
	ll ans = 0;
	cin >> n;
	hei(int) b(n+1), a(n);
	rep(i, 1, n)cin >> b[i];
	b[n]=100000;
	b[0] = 100000;
	rep(i, 0, n) {
		ans += min(b[i],b[i + 1]);
	}
	cout << ans << endl;
	return 0;
	
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N;

int main()
{
    cin >> N;
    vector<int> a(N + 1);
    for (int i = 1; i <= N; i++)
    {
        cin >> a[i];
    }
    vector<int> box(N + 1);
    for (int i = N; i > 0; i--)
    {
        int cnt = 0;
        for (int j = 2; j * i <= N; j++)
        {
            if (box[i * j] > 0)
                cnt++;
        }
        if (cnt % 2 != a[i])
            box[i]++;
    }
    vector<int> st;
    for (int i = 1; i <= N; i++)
    {
        if (box[i] > 0)
            st.push_back(i);
    }
    cout << st.size() << endl;
    for (int i = 0; i < st.size(); i++)
    {
        cout << st[i] << (st.size() - 1 == i ? "\n" : " ");
    }
}

Measured memory_bytes: 3064
import numpy as np
n,m = map(int,input().split())

p = [0 for i in range(n+1)]
q = list()
q2 = list()

g=[[] for i in range(n+1)]

for i in range(m):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)


q2.append(1)

while 1:
    q=q2
    q2=[]

    while len(q):
        v = q.pop()
        
        for nv in g[v]:
            if p[nv] == 0:
                p[nv]=v
                g[nv].remove(v)
                q2.append(nv)
    if len(q2)==0:
        break

if 0 in p[2:]:
    print('No')
else:
    print('Yes')
    for q in p[2:]:
        print(q)


Measured memory_bytes: 52124
#include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int a[MAX_V] = {'0'};
int sum[MAX_V+1];
int main() {
  int i, k, v, j, m, n;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  sum[0] = 0;
  for(m = 0; m < MAX_V; m++) {
    sum[m+1] = sum[m] + prime[m];
  }
  while( scanf( "%d", &n ) != EOF ) {
    for( j = 2; j <= n; j++ ) {
      int isprime = prime[j];
      int isprimee = prime[j-2];
    }
    printf( "%d\n", sum[n+1] );
  }
  return 0;
}

Measured memory_bytes: 8840
#include<bits/stdc++.h>
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 Would
#define you
#define please


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

	
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	if (N <= K) co(N * X);
	else co(N * Y + K * (X - Y));

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using Int = long long;  // clang-format off
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat Jul 11 21:13:30 JST 2020
 **/

template <class T, class S> T make_vec(S x) { return x; }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return std::vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

Int solve(Int x) {
    Int ret = 0;
    while (x) {
        ret++;
        x %= __builtin_popcountll(x);
    }
    return ret;
}
signed main() {
    Int n;
    std::string s;
    std::cin >> n >> s;
    Int cnt = std::count(s.begin(), s.end(), '1');
    auto pows = make_vec<Int>(n, 3, 1);
    std::vector<Int> rem(3);
    REP(dif, 3) {
        Int acc = 0;
        Int mod = cnt + dif - 1;
        if (mod <= 0) continue;
        for (Int i = n - 1; i >= 0; i--) {
            if (i < n - 1) pows[i][dif] = pows[i + 1][dif] * 2 % mod;
            acc += pows[i][dif] * (s[i] == '1');
            acc %= mod;
        }
        rem[dif] = acc;
    }
    REP(i, n) {
        Int x = s[i] == '1' ? rem[0] - pows[i][0] : rem[2] + pows[i][2];
        Int mod = s[i] == '1' ? cnt - 1 : cnt + 1;
        if (mod == 0) {
            std::cout << 0 << "\n";
        } else {
            x += mod;
            x %= mod;
            std::cout << 1 + solve(x) << "\n";
        }
    }
}


Measured memory_bytes: 14340
#include<bits/stdc++.h>
using namespace std;
main(){
  while(1){
    long long n,m;
    long long sum=0;
    cin>>n>>m;
    if(n==0&&m==0) break;
    long long p[1005];
    for(int i=0;i<n;i++){
      cin>>p[i];
      sum+=p[i];
    }
    sort(p,p+n,greater<long long>());
    for(int i=1;i<=n;i++){
      if(i%m==0){
	sum-=p[i-1];
      }
    }
    cout<<sum<<endl;
  }
}

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

int main()
{
    int a;
    int b;
    int c;
    
    cin >> a >> b >> c;
    
    int count = 0;
    
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            count += 1;
        }
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n,m;
	
	cin >> n >> m;
	
	int k;
	vector<int> fav(m+1,0);
	int tmp;
	
	for (int i = 0; i < n; i++) {
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> tmp;
			fav.at(tmp)++;
		}
	}
	
	int ans;
	
	for (int i = 1; i < m+1; i++) {
		if (fav.at(i) == n) {
			ans++;
		}
	}
	
	cout << ans << endl;
	
	
	return 0;
}


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;


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

const ll MOD = 1e9 + 7;



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}
/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);
	return (x / tmp) * y;
}


/******************************************************************************************/


int main() {


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

	int mini = INF;
	int tmp = 0;
	for (int i = 0; i < n - 1; i++)
	{
		tmp += a[i];
		int hoge2 = sum - tmp;
		//cout << hoge2 << endl;
		mini = min(mini,abs(tmp-hoge2));
		//cout << sum << " " << tmp << " " << mini << endl;
	}
	cout << mini << endl;







	return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	switch s {
	case "SUN":
		fmt.Println(7)
	case "MON":
		fmt.Println(6)
	case "TUE":
		fmt.Println(5)
	case "WED":
		fmt.Println(4)
	case "THU":
		fmt.Println(3)
	case "FRI":
		fmt.Println(2)
	case "SAT":
		fmt.Println(1)
	}
}


Measured memory_bytes: 512
//標準解答
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

main(){
    int n, A[1000];
    
    while(1){
        cin >> n;
        if ( n == 0 ) break;
        
        for ( int i = 0; i < n; i++ ) cin >> A[i];
        int sum = 0;
        for ( int i = 0; i < n; i++ ) sum += A[i];
        double avg = 1.0*sum/n;
        double dist = 0.0;
        for ( int i = 0; i < n; i++ ){
            dist += (avg-A[i])*(avg-A[i]);
        }
        
        printf("%lf\n", sqrt(dist/n));
    }
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,n) for(lli i=0;i<n;i++)
#define repb(i,n) for(lli i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define bg() begin()
#define en() end()
#define ft first
#define sc second
#define vect_lli_it vector<lli>::iterator
#define set_lli_it set<lli>::iterator
#define inf 1e18
#define all(X) X.begin(),X.end()
#define iterate(X) for(it=X.begin();it!=X.end();it++)
lli combi(lli n,lli k)
{
    lli ans=1;
    k=k>n-k?n-k:k;
    lli j=1;
    for(;j<=k;j++,n--)
    {
        if(n%j==0)
        {
            ans*=n/j;
        }else
        if(ans%j==0)
        {
            ans=ans/j*n;
        }else
        {
            ans=(ans*n)/j;
        }
    }
    return ans;
}
lli gcd(lli a, lli b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
lli findlcm(vector <lli> arr, lli n)
{
    lli ans = arr[0];
    for (lli i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
lli power(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    if (x == 0) return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y);
lli modInverse(lli b, lli m)
{
    lli x, y;
    lli g = gcdExtended(b, m, &x, &y);
    if (g != 1)
        return -1;
    return (x%m + m) % m;
}
lli modDivide(lli a, lli b, lli m)
{
    a = a % m;
    lli inv = modInverse(b, m);
    return (inv * a) % m;
}
lli gcdExtended(lli a, lli b, lli *x, lli *y)
{
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }
    lli x1, y1;
    lli gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin>>n;
    string s;
    vector <lli> arr;
    
    while(n>0){
    	arr.pb(n%26);
    	n=n/26;
	}
	//reverse(all(arr));
//	rep(i,arr.size())
//	cout<<arr[i]<<" ";
	rep(i,(lli)arr.size()){
		if(arr[i]>0){
			s+=char(97+arr[i]-1);
		}
		else{
			if(arr[i]==0){
				if(i+1<(lli)arr.size()){
					s+='z';
					arr[i+1]-=1;
				}
			}
			else{
				if(i+1<(lli)arr.size()){
					s+='y';
					arr[i+1]-=1;
				}
			}
		}
	}
	reverse(all(s));
	cout<<s;
    return 0;
}


Measured memory_bytes: 3680
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

def get_divs(n):
	m = n**0.5
	divs = set()
	i = 1
	while i <= m:
		if n % i == 0:
			divs.add(i)
			divs.add(n//i)
		i += 1
	return divs

B = [0] * N

R = [0] * N
for i in range(N-1, -1, -1):
	if R[i] % 2 == A[i]:
		B[i] = 0
	else:
		B[i] = 1
		n = i+1
		for v in get_divs(n):
			R[v-1] += 1

ans = [i+1 for i, b in enumerate(B) if b == 1]
print(len(ans))
print(*ans)


Measured memory_bytes: 101732
#include<bits/stdc++.h>
#define gc getchar
#define re register
#define rep(i,s,t) for(re int i=s;i<=t;++i)
 
using namespace std;
typedef long long ll;
 
const int N=2005;
const ll Mod=1e9+7;
int n,m,s[N],t[N];
ll dp[N][N];
 
inline int read(){
  int rt=0;
  char ch=gc();
  while(ch<'0'||ch>'9')ch=gc();
  while(ch>='0'&&ch<='9'){
    rt=(rt<<3)+(rt<<1)+(ch&15);
    ch=gc();
  }
  return rt;
}
int main(){
  n=read(),m=read();
  rep(i,1,n)s[i]=read();
  rep(i,1,m)t[i]=read();
  rep(i,0,n)dp[i][0]=1;
  rep(j,0,m)dp[0][j]=1;
  rep(i,1,n)rep(j,1,m)dp[i][j]=((dp[i-1][j]+dp[i][j-1]-(s[i]==t[j]?0ll:dp[i-1][j-1]))%Mod+Mod)%Mod;
  return not printf("%lld",dp[n][m]);
}

Measured memory_bytes: 31616
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let line = read_as_vec::<usize>();
    let (_, _, k) = (line[0], line[1], line[2]);
    let mut a: Vec<usize> = read_as_vec();
    let mut b: Vec<usize> = read_as_vec();
    let mut a_acc = vec![0; a.len() + 1];
    let mut b_acc = vec![0; b.len() + 1];
    // a.reverse();
    // b.reverse();

    let mut acc = 0;
    for i in 0..a.len() {
        a_acc[i] = acc;
        acc += a[i];
    }
    a_acc[a.len()] = acc;

    let mut acc = 0;
    for i in 0..b.len() {
        b_acc[i] = acc;
        acc += b[i];
    }
    b_acc[b.len()] = acc;
    // println!("{:?}", a_acc);
    // println!("{:?}", b_acc);
    let mut ans = 0;
    for a_read_num in 0..a_acc.len() {
        if a_acc[a_read_num] > k {
            continue;
        }
        let (mut left, mut right) = (0, b_acc.len());
        //println!("a read num = {}", a_read_num);
        while left + 1 < right {
            let mid = (left + right) / 2;
            //println!("mid = {}", mid);
            if a_acc[a_read_num] + b_acc[mid] > k {
                right = mid;
            } else {
                left = mid;
            }
        }
        //println!("{}", a_read_num + left);
        ans = cmp::max(ans, a_read_num + left);
    }

    println!("{}", ans);
}


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

int main(){
    int long long H, N;
    int long long A = 0;
    cin >> H >> N;
    vector<int> V(N);
    for(int i = 0; i < N; i++){
        cin >> V.at(i);
        A = A + V.at(i);
    }
    if(A >= H){
        cout << "Yes" << endl;
    }
    else if(A < H){
        cout << "No" << endl;
    }
    return 0;
}

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

int main()
{
    int x,y;
    scanf("%d %d",&x,&y);
    int v = y-2*x;
    if(v>=0 && (v%2==0) && (x-(v/2))>=0) printf("Yes\n");
    else printf("No\n");
}


Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (ll i = (a); i < (n); i += (s))
#define rep(...) _overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void chmax(T& a, const T& b) {if (a < b) a = b;}
template<typename T> inline void chmin(T& a, const T& b) {if (a > b) a = b;}
template<typename T> inline void print(const T& x) {cout << x << "\n";}
struct Init {Init() {cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10);}} init;

int main() {
    string s;
    cin >> s;
    reverse(all(s));
    ll idx = 0;
    bool isOk = true;
    while (idx < sz(s)) {
        if (s.substr(idx, 5) == "maerd") idx += 5;
        else if (s.substr(idx, 7) == "remaerd") idx += 7;
        else if (s.substr(idx, 5) == "esare") idx += 5;
        else if (s.substr(idx, 6) == "resare") idx += 6;
        else {isOk = false; break;}
    }
    if (isOk) print("YES");
    else print("NO");
}

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

public class Main {


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

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] s = str.split(" ");
        int[] n = new int[s.length];
        for (int i = 0; i < n.length; i++) {
            n[i] = Integer.parseInt(s[i]);
        }
        if ( n.length == 3 ) {
            if ( n[0] < n[1] && n[1]< n[2] && n[0] < n[2]){
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 24296
/* ----------------------------
 * ABC 81 A
 * ---------------------------- */
#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int ans = 0;
	while(n){
		ans += n%10;
		n /= 10;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int sets[10000];

void same(int smaller, int greater) {
  if (smaller == greater)
    printf("1\n");
  else if (sets[greater] < smaller)
    same(sets[greater], smaller);
  else if (smaller != sets[smaller])
    same(sets[smaller], greater);
  else if (greater != sets[greater])
    same(smaller, sets[greater]);
  else
    printf("0\n");
}

void unite(int smaller, int greater) {
  if (sets[greater] < smaller)
    unite(sets[greater], smaller);
  else if (smaller != sets[smaller])
    unite(sets[smaller], greater);
  else if (greater != sets[greater])
    unite(smaller, sets[greater]);
  else
    sets[greater] = smaller;
}

int main(void) {
  int n, q, i, j;
  scanf(" %d %d", &n, &q);
  for (i = 0; i < 10000; i++)
    sets[i] = i;
  for (i = 0; i < q; i++) {
    int command, in0, in1;
    scanf(" %d %d %d", &command, &in0, &in1);
    if (command)
      in0 < in1 ? same(in0, in1) : same(in1, in0);
    else
      in0 < in1 ? unite(in0, in1) : unite(in1, in0);
  }
  return 0;
} 	



Measured memory_bytes: 2128
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
pair<int, int> x[100010];
int main()
{
	int n;
	scanf("%d", &n);
	int ch = 0;
	for (int i = 1; i <= n; i++)
	{
		int q;
		scanf("%d %d %d",&q, &x[i].first, &x[i].second);
		int dap = abs(x[i].first - x[i - 1].first) + abs(x[i].second - x[i - 1].second);
		int o = q-ch;
		if (dap > o || dap % 2 != o % 2)
		{
			puts("No");
			return 0;
		}
		ch = q;
	}
	puts("Yes");
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

int N, A, B, C;
int l[10];

int slv(int i, int a, int b, int c)
{
  if (i >= N) {
    if (a <= 0 || b <= 0 || c <= 0)
      return INF;
    else
      return abs(A-a) + abs(B-b) + abs(C-c) - 30;
  }

  return min({
      slv(i+1, a+l[i], b, c) + 10,
      slv(i+1, a, b+l[i], c) + 10,
      slv(i+1, a, b, c+l[i]) + 10,
      slv(i+1, a, b, c)
  });
}

signed main()
{
  cin >> N >> A >> B >> C;
  for (int i = 0; i < N; ++i) {
    cin >> l[i];
  }

  cout << slv(0, 0, 0, 0) << endl;

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
using namespace std;
# define INF (1<<29)
int N, M, R;
int d [201][201];
int r [9];
int A, B, C;
int res ;
bool used [9];
void dfs (int c , int las , int dist)
{
  if ( c == R +1)
  {
    if ( res > dist ) res = dist ;
    return ;
  }
  for ( int i =1; i <= R ; i ++) if (!used [i])
  {
    used [ i ]= true ;
    if ( las == -1) dfs (c+1,i ,0);
    else dfs ( c +1 ,i , dist + d [ r[las]][r[i]]);
    used [ i ]= false ;
  }
}
int main ()
{
  scanf ("%d %d %d" ,&N ,&M ,&R);
  for ( int i =1; i <= N ; i++) for ( int j =1; j <= N ; j ++) if ( i != j ) d [i][j]= INF;
  for ( int i =1; i <= R ; i++) scanf ("%d" ,&r[i]);
  for ( int i =1; i <= M ; i++)
  {
    scanf ("%d %d %d " ,&A ,&B ,&C);
    if ( d [A][B] > C ) d [A][B]= d [B][A]= C ;
  }
  for ( int k =1; k <= N ; k ++)
    for ( int i =1; i <= N ; i ++)
      for ( int j =1; j <= N ; j ++)
        if ( d [i][j] > d [i][k]+ d [k][j])
          d[i][j]= d [i][k]+ d [k][j];
  res = INF;
  dfs (1 , -1 ,0);
  printf ("%d\n " , res );
}


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007
//グリッドグラフの範囲チェック
bool range_validation(int y,int x,int h,int w){
    return y>=0 && y<h && x>=0 && x < w;
}
//ビットカウント
int popcount(long bits){
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

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

vector<ll> sieve(ll n){
  vector<bool> is_prime(n+1,true);
  vector<ll> res;
  for(int i=2;i<=n;i++){
    if(is_prime[i]){
      res.push_back(i);
      for(int j=2*i;j<=n;j+=i){
        is_prime[j] = false;
      }
    }
  }
  return res;
}

vector<ll> divisor(ll n){
  vector<ll> list;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      list.push_back(i);
      if(n/i != i){
        list.push_back(n/i);
      }
    }
  }
  return list;
}

umap<int,int> prime_factor(ll n){
  umap<int,int> fac;
  for(int i=2;i*i<=n;i+=2){
    if(n%i == 0){
      int count = 0;
      while(n%i == 0){
        count++;
        n /= i;
      }
      fac[i] = count;
    }
  }
  if(n!=1)fac[n] = 1;
  return fac;
}
struct edge
{
  int to;
  int len;
};

int n;
vector<vector<edge>> graph;
vector<int> color;
void dfs(int v,int now_color){
  color[v] = now_color;
  for(auto e : graph[v]){
    if(color[e.to]!=-1)continue;

    if(e.len%2==0){
      dfs(e.to,now_color);
    }else{
      dfs(e.to,1-now_color);
    }
  }
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  cin >> n;
  graph.resize(n);
  int u,v,w;
  REP(i,n-1){
    cin >> u >> v >> w;
    u--;v--;
    graph[u].push_back(edge{v,w});
    graph[v].push_back(edge{u,w});
  }

  color.resize(n);//0 黒 1白
  REP(i,n)color[i] = -1;

  dfs(0,0);
  REP(i,n){
    cout << color[i] << endl;
  }


  return 0;
}


Measured memory_bytes: 10924