akhauriyash/Code-Regression huggingface dataset:
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;
typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<(x)<<endl
#define p2(x,y)                 out<<(x)<<' '<<(y)<<endl
#define p3(x,y,z)               out<<(x)<<' '<<(y)<<' '<<(z)<<endl
#define p4(x,y,z,w)             out<<(x)<<' '<<(y)<<' '<<(z)<<' '<<(w)<<endl
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<(ix == n-1? '':' '); out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define pl(x)                   out<<(x)
#define pll(x)                  out<<(x)<<' '
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

#define EACH(x, a) for (auto& x: a)
template<class T> void read_v(T& x, std::istream& in) {
    in >> (x);
}
template<class A> void read_vec(vector<A>& x, std::istream& in) {
    EACH(a, x)
        read_v(a, in);
}

bool sortpairbysec(const pair<int,int> &a,const pair<int,int> &b){return (a.second < b.second);}
template <typename T>
T factmod(T a, T modulus){ int res = 1, i; for (i = 2; i <= a; i++){ res *= i; res%=modulus;} return res; }
template <typename T>
int powmod(T a,T b,int m){ int ans=1; while(b>0){if(b&1){ans*=a;ans%=m;}a*=a;a%=m;b>>=1;} return ans; }
template <typename T>
int power(T a, T b){ int ans=1; while(b>0){if(b&1){ans*=a;}a*=a;b>>=1;}return ans;}

const int CMOD = 1e9 + 7;

void ssolve(std::istream& in, std::ostream& out){
    int n; s(n);
    int ans = 1;
    if(n==1){p(0); return;}
    if(n==2){p(2); return;}
    int t1 = 1;
    for(int i = 0; i < n; i++){
        t1 *= 10;
        t1 %= CMOD;
    }
    int t2 = 2;
    for(int i = 0; i < n; i++){
        t2 *= 9;
        t2 %= CMOD;
    }
    int t3 = 1;
    for(int i = 0; i < n; i++){
        t3 *= 8;
        t3 %= CMOD;
    }
    ans = t1 - t2 + t3;
    ans %= CMOD;
    ans = (ans>0?ans:ans+CMOD);
    p(ans);
    return;
}

class CUbiquity {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(nullptr);out.tie(nullptr);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    CUbiquity solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  vector<ll> v1, v2, v3, v4;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    v1.push_back(x + y);
    v2.push_back(-x + y);
    v3.push_back(x - y);
    v4.push_back(-x - y);
  }
  ll ans =
      *max_element(v1.begin(), v1.end()) - *min_element(v1.begin(), v1.end());
  ans = max(ans, *max_element(v2.begin(), v2.end()) -
                     *min_element(v2.begin(), v2.end()));
  ans = max(ans, *max_element(v3.begin(), v3.end()) -
                     *min_element(v3.begin(), v3.end()));
  ans = max(ans, *max_element(v4.begin(), v4.end()) -
                     *min_element(v4.begin(), v4.end()));
  cout << ans << endl;
}


Measured memory_bytes: 9760
#include <stdio.h>
#define x 10000

int main(){
  int i,j,n,q,c,S[x],T[x],key;
  c =0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]) {c++; break;}
    }
  }
  printf("%d\n",c);
  return 0;
  
}

Measured memory_bytes: 644
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <utility>
#include <fstream>

using namespace std;
typedef long long ll;

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; }
template<typename T> T gcd(T a, T b) { a = abs(a), b = abs(b); while (b > 0) { tie(a, b) = make_pair(b, a % b); } return a; }
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 1000000007LL;

struct StronglyConnectedComponents {
	int n, group_num, now_ord;
	vector<vector<int>> g;
	vector<int> low, ord, idx;
	StronglyConnectedComponents(int _n) :n(_n), low(n), ord(n, -1), idx(n), g(n), group_num(0), now_ord(0) {}
	void add_edge(int from, int to) {
		g[from].emplace_back(to);
	}
	void dfs(int cur, vector<int> &visited) {
		ord[cur] = low[cur] = now_ord++;
		visited.emplace_back(cur);
		for (auto nxt : g[cur]) {
			if (ord[nxt] == -1) {
				dfs(nxt, visited);
				chmin(low[cur], low[nxt]);
			}
			else {
				chmin(low[cur], ord[nxt]);
			}
		}
		if (ord[cur] == low[cur]) {
			while (true) {
				int v = visited.back();
				visited.pop_back();
				ord[v] = n; //別のdfs木からこないように
				idx[v] = group_num;
				if (cur == v) break;
			}
			group_num++;
		}
	}

	//sccのidxに入ってる頂点番号 idxはトポロジカル順
	vector<vector<int>> build() {
		vector<int> visited;
		for (int i = 0; i < n; i++) if (ord[i] == -1) dfs(i, visited);
		for (int i = 0; i < n; i++) idx[i] = group_num - 1 - idx[i];
		vector<vector<int>> groups(group_num);
		for (int i = 0; i < n; i++) {
			groups[idx[i]].emplace_back(i);
		}
		return groups;
	}
};

int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int n, m; cin >> n >> m;
	StronglyConnectedComponents scc(n);
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		scc.add_edge(a, b);
	}
	auto g = move(scc.build());
	cout << g.size() << "\n";
	for (int i = 0; i < g.size(); i++) {
		cout << g[i].size();
		for (auto& e : g[i]) cout << " " << e;
		cout << "\n";
	}
	return 0;
}

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

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)
#define sz(x) int32_t(x.size())

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// --------------------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9 + 7;
const int INF = 2e18;
const ld EPS = 1e-9;
const int NN = 1e5 + 2;

map<int, int> cache;

int up(int x, int k) {
	return x/k + (x%k > 0);
}

vi nums = {2, 3, 5};

vi costs(4);

int DP_recur(int x) {
	if(cache.count(x))
		return cache[x];
	int ans = INF;
	for(int i = 0; i < 3; i++) {
		int k = nums[i], add = costs[i];
		int v = x/k, v_ = up(x, k);
		if(v > 0) {
			int d = DP_recur(v);
			int a = INF;
			if(abs(v * k - x) < INF / costs[3])
				a = d + costs[3] * abs(v * k - x) + add;
			remin(ans, a);
			if(x - v < INF / costs[3])
				remin(ans, (x - v) * costs[3] + d);
		}
		int d = DP_recur(v_);
		if(abs(v_ * k - x) < INF / costs[3])
			remin(ans, d + costs[3] * abs(v_ * k - x) + add);
		if(x - v_ < INF / costs[3])
			remin(ans, d + costs[3] * (x - v_));
	}

	// cout << x << el;
	return cache[x] = ans;
}

void solve() {
      int n, i;
	cin >> n;

	fr(i, 0, 4) cin >> costs[i];

	cache.clear();
	cache[1] = 0;
	cout << DP_recur(n) + costs[3] << el;
}

int32_t main() {
	cache[1] = 0;
	ios::sync_with_stdio(false); cin.tie(0);
	int T = 1;
	cin >> T;
	for(int tc = 1; tc <= T; tc++) {
		solve();
	}
	return 0;
}

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

int main()
{
  int64_t N, a, ans = 0;
  cin >> N;
  vector<int64_t> A(N), B(N), C(N);
  for (int64_t i = 0; i < N; i++)
    cin >> A.at(i);
  for (int64_t i = 0; i < N; i++)
    cin >> B.at(i);
  for (int64_t i = 0; i < N; i++)
    cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  for (int64_t i = 0; i < N; i++)
  {
    int64_t b = B.at(i);
    auto a_itr = lower_bound(A.begin(), A.end(), b);
    int64_t a = distance(A.begin(), a_itr);
    auto c_itr = upper_bound(C.begin(), C.end(), b);
    int64_t c = N - distance(C.begin(), c_itr);
    ans += a * c;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
import numpy as np

def main():
  n,m = map(int,input().split())
  an = np.array([list(input()) for i in range(n)])
  bm = np.array([list(input()) for i in range(m)])
  
  for i in range(n-m+1):
    for j in range(n-m+1):
      if (an[i:i+m,j:j+m] == bm).all():
        print('Yes')
        exit()
  print('No')
if __name__ == '__main__':
    main()

Measured memory_bytes: 12452
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

void solve()
{
    char c;
    cin>>c;
    char d=c+1;
    cout<<d<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3472
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
DbgTimer D_t;
  #define TSTART() D_t.start()
  #define TSTOP() D_t.stop()
#else
  #define DUMP(i) 
  #define TSTART()
  #define TSTOP()  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  while(cin >> n >> k){
    TSTART();

    int ans = 1;
    REP(i,n){
      ans = min(ans * 2, ans + k);
    }
    cout << ans << endl;
    
    TSTOP();
  }
  return 0;
}


Measured memory_bytes: 256
use itertools::Itertools;
use proconio::input;

fn main() {
  input! {
    _: i64,
    c: String
  }
  let cs = c.chars().sorted();
  let r = c.chars().zip(cs).filter(|(a, b)| (*a, *b) == ('W', 'R')).count();
  
  println!("{}", r);
}



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

using namespace std;

inline void Boost() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
}
typedef long long int ll;
typedef long double ld;

int main() {
	Boost();

	ll n, k; cin >> n >> k;
	vector < ll > v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];

	ll ans = 0;
	for (int i = 1; i < n; ++i) {
		ll dif = max(0LL, v[i] + v[i - 1] - k);
		ans += dif;
		v[i] = max(0LL, v[i] - dif);
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}
 
signed main() {
    int n, m, p;
    while(cin >> n >> m >> p, n || m || p) {
        m--;
        vector<int> v(n);
        int sum = 0;
        rep(i,0,n) {
            cin >> v[i];
            sum += v[i];
        }
        if(v[m] == 0) cout << 0 << endl;
        else cout << sum  * (100 - p) / v[m] << endl;
    }
    return 0;
}

Measured memory_bytes: 3024
#include <stdio.h>
#include <string.h>
int main()
{
 

    char s[100], p[100] ,ss[201] ;



	scanf("%s", s);
	scanf("%s", p);

	strcat( ss, s );
	strcat( ss, s );


	if ( strstr( ss , p ) != '\0' )
		printf("Yes\n") ;
	else 
		printf("No\n") ;
return 0;
}

Measured memory_bytes: 532
import java.math.BigInteger;
import java.util.Scanner;


public class Main
{

	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int dataset = scan.nextInt();
		for(int i = 0; i < dataset; i++)
		{
			BigInteger a = scan.nextBigInteger();
			BigInteger b = scan.nextBigInteger();
			String sum = a.add(b).toString();
			System.out.println(sum.length() > 80 ?  "overflow" : sum);
		}
	}
}

Measured memory_bytes: 18416
#include <math.h>
#include <iostream>
#include <stdio.h>

using namespace std;
typedef long long ll;

int main() {
    ll N;
    cin >> N;
    ll B[1000001];
    for(ll i=0;i<1000001;i++) B[i] = 0;
    ll A[N];
    for(ll i=0;i<N;i++){
        cin >> A[i];
        B[A[i]]++;
    }
    ll out = N;
    for(ll i=0;i<N;i++){
        for(ll j=1;j<=sqrt(A[i]);j++){
            if(A[i]%j==0){
                if(A[i]==1){
                    if((B[j]>1)){
                        out--;
                        break;
                    }
                }else if(B[j]>0){
                    out--;
                    break;
                }else if(j==1){
                    if(B[A[i]/j]>1){
                        out--;
                        break;
                    }
                }else{
                    if(B[A[i]/j]>0){
                        out--;
                        break;
                    }
                }
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 13048
# input
W, H, N = map(int, input().split())
a1 = 0
a2 = W
a3 = 0
a4 = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if x >= a1:
            a1 = x
    if a == 2:
        if x <= a2:
            a2 = x
    if a == 3:
        if y >= a3:
            a3 = y
    if a == 4:
        if y <= a4:
            a4 = y

ans = max(0, (a2 - a1)) * max(0, (a4 - a3))
print(ans)

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

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

int main()
{
	int n;
	cin>>n;
	rep(i,n){
		string s;
		cin>>s;
		vector<int> a;
		string num;
		for(auto x:s){
			if(x=='['){
				a.push_back(1);
			}else if(x==']'){
				if(num!="")	a.push_back(stoi(num));
				num="";
				a.push_back(-1);
			}else{
				num+=x;
			}
		}
		// cout<<endl;
		// rep(i,a.size())cout<<a[i]<<" ";
		// cout<<endl;

		stack<int> ss;
		for(auto x:a){
			if(x!=-1)ss.push(x);
			if(x==-1){
				vector<int> vote;
				while(!ss.empty()){
					int p = ss.top();ss.pop();
					if(p==1)break;
					vote.push_back(p);
				}
				sort(all(vote));

				// cout<<endl;
				// rep(i,vote.size())cout<<vote[i]<<" ";
				// cout<<endl;

				if(vote.size()==1) ss.push(vote[0]/2+1);
				else{
					int res=0;
					rep(j,vote.size()/2+1)res+=vote[j];
					ss.push(res);
				}

			}
		}
		int ans=0;
		while(!ss.empty()){
			// cout<<ss.top()<<" ";
			ans+=ss.top(),ss.pop();
		}
		// cout<<endl;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3280
S = input()

words = ["dream", "erase", "dreamer", "eraser"]
index = 1

while(S):

    if index > len(S):
        print("NO")
        break

    if S[-index:] in words:

        S = S[:-index]
        index = 1
        continue

    index += 1

if not S:
    print("YES")



Measured memory_bytes: 3188
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt(),count=0,sum=0;
		int[] a=new int[8];
		for(int i=0;i<n;i++) {
			int buff=sc.nextInt();
			if(buff<400)a[0]=1;
			else if(buff<800)a[1]=1;
			else if(buff<1200)a[2]=1;
			else if(buff<1600)a[3]=1;
			else if(buff<2000)a[4]=1;
			else if(buff<2400)a[5]=1;
			else if(buff<2800)a[6]=1;
			else if(buff<3200)a[7]=1;
			else count++;
		}
		for(int i=0;i<8;i++)sum+=a[i];
		System.out.println((int)Math.max(sum, 1)+" "+(sum+count));
	}
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int N, M, Q;
int ans = 0;
vector<int> a, b, c, d;

void dfs(vector<int> &A)
{
  rep(i, A.size() - 1)
  {
    if (A[i] > A[i + 1])
      return;
  }
  // 数列の長さが N に達したら打ち切り
  if (A.size() == N)
  {
    int score = 0;
    rep(i, Q)
    {
      if (A[b[i]] - A[a[i]] == c[i])
        score += d[i];
    }
    ans = max(score, ans);
    return;
  }
  for (int v = 1; v <= M; ++v)
  {
    A.push_back(v);
    dfs(A);
    A.pop_back();
  }
}
int main()
{
  cin >> N >> M >> Q;
  a.resize(Q);
  b.resize(Q);
  c.resize(Q);
  d.resize(Q);
  rep(i, Q)
  {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  vector<int> A(0);
  dfs(A);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int N = s.size();

  int ans = 1;
  REP(i, N/2){
    if(s[i] != s[N/2-i-1]) ans = 0;
  }
  REP(i, N){
    if(s[i] != s[N-i-1]) ans = 0;
  }

  if(ans) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, c;
  cin >> a >> b >> c;
  string ans = "Yes";
  if(a != b && b != c && c != a){
    ans = "No";
  }
  else if(a == b && b == c && c == a){
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
	int N;
	cin >> N;
	int sum=0;
	while (sum <= N){
		if((N-sum)%4==0){
			cout << "Yes"<< endl;
			return 0;
		}
		sum +=7;
	}
	cout <<"No"<< endl;

}




Measured memory_bytes: 256
def main():
    N = int(input())
    L = [0]*(N+1)
    for i in range(1,120):
        for j in range(1,120):
            for k in range(1,120):
                temp =  i**2 + j**2 + k**2 + i*j + j*k + k*i
                if N >= temp:
                    L[temp] += 1
                else:
                    break


    for i in range(1,N+1):
        print(L[i])



if __name__ == '__main__':
    main()


Measured memory_bytes: 68756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 998244353;

ll mod(ll x){
    ll res=x%MOD;
    return res+(res<0?MOD:0);
}
ll inv(ll x){
    ll b=MOD,u=1,v=0;
    while(b){
        ll t=x/b;
        x-=t*b;swap(x,b);
        u-=t*v;swap(u,v);
    }
    return mod(u);
}
vector<ll> prods(int x){
    vector<ll> res(x+1);
    res[0]=1;
    for(int i=1; i<=x; i++)res[i]=mod(i*res[i-1]);
    return res;
}
vector<ll> pows(ll a,int x){
    vector<ll> res(x+1);
    res[0]=1;
    a=mod(a);
    for(ll i=1; i<=x; i++)res[i]=mod(a*res[i-1]);
    return res;
}
ll power(ll a, ll n){
    ll res=1;
    a=mod(a);
    for(;n>0;n>>=1){
        if(n&1)res=mod(res*a);
        a=mod(a*a);
    }
    return res;
}

vector<ll> p;//p=prods(MAX_n)
ll comb(ll a, ll b){
    if(b<0||b>a)return 0;
    return mod(mod(p[a]*inv(p[b]))*inv(p[a-b]));
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,s;cin>>n>>s;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    vector<vector<ll>> dp(n+1);

    
    for(int i=0; i<=n; i++){
        dp[i]=vector<ll>(s+1,0);
        
        if(i==0){dp[i][0]=1;continue;}
        for(int j=0; j<=s; j++){
            dp[i][j]=2*dp[i-1][j];
            dp[i][j]%=MOD;
        }
        for(int j=a[i-1]; j<=s; j++){
            dp[i][j]+=dp[i-1][j-a[i-1]];
            dp[i][j]%=MOD;
        }
    }
    cout<<dp[n][s]%MOD<<endl;
    return 0;
}

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

int main() {

int N;
cin>>N;
vector<long> a(N);
for(int i=0;i<N;i++){
  cin>>a[i];
}
sort(a.begin(),a.end());
if(a[0]==0){
  cout<<0<<endl;
  return 0;
}
long ans=1;

for(int i=0;i<N;i++){
  if(long(1e18)/a[i]<ans){
    cout<<-1<<endl;
    return 0;
  }
  ans*=a[i];


}
cout<<ans<<endl;
}


Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define llu unsigned long long
#define pb push_back
#define eb emplace_back
#define ll long long
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fs(s) for(ll i=0;s[i]!='\0';i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define gcd(a,b) __gcd(a,b)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define c1(x) __builtin_popcountll(x)
#define setprs(x) cout << fixed << setprecision(x);
#define nl '\n'
const ll mod=INT_MAX;
const ll sz=1e5 + 100;
const double PI =3.14159265;
ll power(ll a, ll b, ll m = mod){if(b==0)return 1;else if(b==1)return a%m;else{ll t=power(a,b>>1,m);t=(t * t)%m;if(b&1)return (t * a)%m;else return t;}}
 
//--------------------------------------------------------
#define int long long

int n, W;
int w[sz], v[sz], dp[103][sz], fans;

int dpfunc(int values, int pos){
    if(values <= 0 || pos >= n)
        return 0;
    if(dp[values][pos] != mod)
        return dp[values][pos];
    int ans = 0;
    int i = pos;
    int m1 = dpfunc(values, pos + 1) + dp[values][pos-1];
    int m2 = mod;
    if(values - v[i] >= 0){
        m2 = dpfunc(values - v[i], pos + 1) + w[i] + dp[values][pos-1];
    }
    ans = min(m1, m2);
    cout << m1 << " " << m2 << " ";
    if(ans <= W && ans > 0)fans = max(fans, values);
    return dp[values][pos] = min(dp[values][pos], ans);
}

void solve()
{
    cin >> n >> W;
    int sum = 0;
    f(i, 0, n){
        cin >> w[i] >> v[i];
        sum += v[i];
    }
    f(i, 0, n){
        f(j, 0, sum + 1){
            dp[i][j] = mod;
        }
    }
    dp[0][0] = 0;
    // f(i ,0, sum +1)dp[0][i] = 0;
    // dpfunc(sum, 1);
    dp[0][v[0]] = w[0]; 
    int ans = 0;
    f(i, 1, n){
        f(j, 0, sum + 1){
            dp[i][j] = dp[i-1][j];
            if(j >= v[i])
            dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
        }
    }
    f(i,0,sum+1){
        if(dp[n-1][i] <= W){
            ans = max(ans,i);
        }
    }
    cout << ans;
} 
 
int32_t main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 81752
#include <cstdio>
#include <vector>
#define MAXN 200100
std::vector<int> g[MAXN];
const char* good = "POSSIBLE";
const char* bad = "IMPOSSIBLE";
bool dfs(int v, int p, int depth, int n) {
	bool ans = false;
	if(depth == 2 && v != n) return false;
	else if(depth == 2 && v == n) return true;
	else for(int c: g[v]) if(c != p) ans |= dfs(c, v, depth + 1, n);
	return ans;
}
int main(void) {
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int src, dst;
		scanf("%d%d", &src, &dst);
		g[src - 1].push_back(dst - 1);
		g[dst - 1].push_back(src - 1);
	}
	puts(dfs(0, -1, 0, n - 1) ? good : bad);
	return 0;
}

Measured memory_bytes: 12016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M,max=0,m=0,min=0;
  cin>>N>>M;
  vector<int> a(M);
  vector<int> b(M);
  for(int i=0;i<M;i++){
    cin>>a[i]>>b[i];
    if(i==0) m=b[0];
    if(max<a[i]){
      max=a[i];
    }
     if(m>b[i]){
      m=b[i];
    }
  }
 if(m-max+1<0){
   cout<<0<<endl;
 }
  else{
    cout<<m-max+1<<endl;
  }

}


Measured memory_bytes: 1024
def main():
    
    N = int(input())
    CSF = []
    for i in range(N-1):
        CSF.append(list(map(int, input().split())))
    CSF.append([0,0,1])
    
    # loop
    ans_list = []
    for st in range(N-1):
        ans = CSF[st][1]
        for i in range(st,N-1):
            nex = ans + CSF[i][0]
            if nex <= CSF[i+1][1]:
                ans = CSF[i+1][1]
            else:
                if nex%CSF[i+1][2] == 0:
                    ans = nex
                else:
                    ans = (nex//CSF[i+1][2] + 1) * CSF[i+1][2]

        ans_list.append(ans)
    
    ans_list.append(0)
    
    for ans in ans_list:
        print(ans)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<math.h>
using namespace std;
 int main(){
   int a,b;
   cin >> a >>b;
   int res=0;
   for(int c=1;c<=3;c++){
     if(a*b*c % 2 == 1) res++;
   }
   if(res==0) cout << "No" <<endl;
   else cout << "Yes" <<endl;
   return 0;
 }

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=1e6+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
  }
  
 	
void solve() {
    int n;
    cin>>n;
    vi a(n,0);
    rep(i,0,n) cin>>a[i];
    //~ sort(all(a));
    int ct=0;
    rep(i,0,n) {
		  rep(j,i+1,n) {
			    rep(k,j+1,n) {
					  if(a[i]!=a[j] && a[i]!=a[k] && a[j]!=a[k]) {
						    vi nax;
						    nax.pb(a[i]);nax.pb(a[j]);nax.pb(a[k]);
						    sort(all(nax));
						    if(nax[0]+nax[1]>nax[2]) ct++; 
						  }					     
					}
			  }
		}
		cout<<ct<<endl;   
                       
}

    
int32_t main() {
	cool;
	int t=1;	
  
	//cin>>t;
	while(t--)
	  solve();

  return 0;	   
}


Measured memory_bytes: 3660
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

using namespace std;


void solve() {
    string s, t; cin >> s >> t;

    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] != t[i]) ans++;
    }

    cout << ans << endl;
}


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

Measured memory_bytes: 3832
//#include <bits/stdc++.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <limits>
#include <map>
#include <vector>
#include <queue> 
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
//#define int LL
#define db double
using namespace std;
const int N   = 1e5+233;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}
struct xx
{
	int V,next;
}b[N<<1];
int G,head[N],vis[N],dep[N],mx;
void add(int x,int y)
{
	b[++G]=(xx){y,head[x]};
	head[x]=G;
}
int n,x,y,rt,fa[N];
#define F(x) for (int i=head[x];i;i=b[i].next)
#define v b[i].V
void dfs1(int u,int Fa=0)
{
	if (dep[u]>dep[mx]) mx=u;
	F(u) if (v^Fa) fa[v]=u,dep[v]=dep[u]+1,dfs1(v,u);
}
int son[N],st[N],tp;
void dfs2(int u,int Fa=0)
{
	F(u) if (v^Fa) 
	{
		if (!vis[v]) dep[v]=dep[u]+1,son[u]++;
		dfs2(v,u);
	}
}
int k[N],ans1[N],ans2[N],ok=1;

void solve(int * p)
{
	int nw=0;
	rep(i,1,tp) 
	{
		p[nw+k[i]+1]=nw+1;
		rep(j,1,k[i]) p[nw+j]=nw+j+1;
		nw+=k[i]+1;
	}
}

signed main()
{
	read(n);
	rep(i,2,n) read(x),read(y),add(x,y),add(y,x);
	mx=1;dfs1(1);//
	dep[rt=mx]=0;dfs1(mx);
	for (int k=mx;k^rt;k=fa[k]) vis[st[++tp]=k]=1;vis[st[++tp]=rt]=1;
	memset(dep,0,sizeof(dep));
	dfs2(rt);
	rep(i,1,n) if (dep[i]>1) return printf("-1"),0;
	rep(i,1,tp) k[i]=son[st[i]];
	solve(ans1);
	rep(i,1,tp/2) swap(k[i],k[tp+1-i]);
	solve(ans2);
	rep(i,1,n) if (ans1[i]!=ans2[i])
	{
		if (ans1[i]<ans2[i]) ok=1;
		else ok=2;
		break;
	}
	if (ok==1) rep(i,1,n) printf("%d ",ans1[i]);
	else rep(i,1,n) printf("%d ",ans2[i]);
	return 0; 
}


Measured memory_bytes: 10240
#include<stdio.h>
#include <time.h>

#define SIZE 10000

int main(){
  int n,a,b;
  int temp;
  int sum = 0;
  int grad_sum = 0;

  int i,j;
  scanf("%d",&n);
  scanf("%d",&a);
  scanf("%d",&b);
  for(i = 1;i <= n; i++){
    j = i;
    do{
      sum += j % 10;


    }while((j = j / 10) > 0);
    if(sum >= a && sum <= b)
      grad_sum += i;
    sum = 0;
  }
  printf("%d\n",grad_sum);
  return 0;
}


Measured memory_bytes: 128
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;
int main(){
  int X,A,B;
  cin>> X >> A >> B;
  if(A+X >= B){
    if(A >= B){
      cout<< "delicious" <<endl;
    }else{
      cout<< "safe" <<endl;
    }
  }else{
    cout<< "dangerous" <<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "string"
using namespace std;
int main()
{
    
    string s, t;
    cin >> s >> t;
    if (s == t.substr(0, t.length() - 1))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 3640
#include<iostream>  
#include<cstdio>  
#include<cstring>  
#include<cmath>  
using namespace std;  
const int N=100000+5;  
struct Edge{int to,next;}e[N<<1];  
int head[N],cnt;  
void ins(int u,int v){  
    e[++cnt]=(Edge){v,head[u]};head[u]=cnt;  
}  
int f[N],bin[30],s[N],m,c[30];  
void dp(int u,int fa){  
     int sv=0,cu=0,son=0;  
     for(int i=head[u];i;i=e[i].next){  
        int v=e[i].to;if(v==fa)continue;  
        dp(v,u);  
        sv|=s[v];  
        son++;  
     }  
     if(!son){  
        f[u]=0;  
        s[u]=1;  
        return;  
     }  
     memset(c,0,sizeof(c));  
     for(int i=head[u];i;i=e[i].next)  
     if(e[i].to!=fa)  
     for(int j=0;j<m;j++)  
     if(s[e[i].to]&(1<<j))c[j]++;  
     if(son>1)  
     for(int i=m-1;i>=0;i--)  
     if(c[i]>=2){  
        cu=i+1;  
        break;  
     }  
     for(int i=cu;i<m;i++)  
     if(!(sv&(1<<i))){  
        cu=i;  
        break;  
     }  
     s[u]=((sv>>cu)|1)<<cu;  
     f[u]=cu;  
     for(int i=head[u];i;i=e[i].next)  
     if(e[i].to!=fa)  
     f[u]=max(f[u],f[e[i].to]);  
}  
int main(){  
    //freopen("a.in","r",stdin);  
    //freopen("a.out","w",stdout);   
    int n;scanf("%d",&n);m=log2(n)+1;  
    for(int i=1;i<n;i++){  
         int u,v;scanf("%d%d",&u,&v);  
         ins(u,v);ins(v,u);  
    }  
    dp(1,0);  
    printf("%d\n",f[1]);  
    return 0;  
}  


Measured memory_bytes: 8704
/* ITP1_1_C: Rectangle*/
/* 20181118 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void){
	int a, b;

	scanf("%d %d", &a, &b);
	printf("%d %d\n", a * b, 2 * (a + b));

	return 0;
}


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

int main() {
    int m;
    cin >> m;
    long long digit = 0;
    long long digit_sum = 0;
    for (int i = 0; i < m; i++) {
        long long d, c;
        cin >> d >> c;
        digit += c;
        digit_sum += d * c;
    }
    
    long long ans = (digit_sum <= 9 ? 0 : ((digit_sum - 10) / 9 + 1)) + (digit - 1);
    cout << ans << endl;
}

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

bool isPalindrome(int n)
{
    vector<int> A;
    while(n > 0)
    {
        A.push_back(n % 10);
        n /= 10;
    }

    int a_len = A.size();

    for (int i = 0; i < a_len / 2; i++)
    {
        if (A.at(i) != A.at(a_len - 1 - i))
        {
            return false;
        }
    }
    return true;
}

int main()
{
    int A, B;
    cin >> A >> B;

    int res = 0;

    for (int i = A; i <= B; i++)
    {
        if(isPalindrome(i))
        {
            res++;
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long n = tmp[0], m = tmp[1];

    writeln((100 * (n - m) + 1900 * m) * 2 ^^ m);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

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

ans = 'Yes'
for i, step in enumerate(S):
    odd_even = (i+1) % 2
    if odd_even == 0:
        if step != 'L' and step != 'U' and step != 'D':
            ans = 'No'
            break
    elif odd_even == 1:
        if step != 'R' and step != 'U' and step != 'D':
            ans = 'No'
            break
print(ans)

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

#define rep(i,N) repv(i,0,N)
#define reps(i,N) repvs(i,0,N)
#define repv(i,a,b) for(int i=a;i<b;i++)
#define repvs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<","
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d
#define da(arr,N){if(isDebugMode){rep(i,N+1){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N+1){rep(j,M+1){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back
#define s(a) cout<<a<<endl;

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 100000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
int n,W;
vector<int> b[4];
int w1;
void solve(){
	int ans=0;
	rep(i,4){
		sort(b[i].begin(),b[i].end(),greater<int>());
	}
	rep(i,b[0].size()+1){
		rep(j,b[1].size()+1){
			rep(k,b[2].size()+1){
				rep(l,b[3].size()+1){
					ll w=0;
					int v=0;
					rep(a,i){
						w+=w1;
						v+=b[0][a];
					}
					rep(a,j){
						w+=w1+1;
						v+=b[1][a];
					}
					rep(a,k){
						w+=w1+2;
						v+=b[2][a];
					}
					rep(a,l){
						w+=w1+3;
						v+=b[3][a];
					}
					if(w<=W) chmax(ans,v);
				}
			}
		}
	}
	s(ans);
}

int main(){
	cin>>n>>W;
	rep(i,n) {
		int w,h;
		cin>>w>>h;
		if(i==0)w1=w;
		b[w-w1].pb(h);
	}
	solve();
	return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n){
        cin >> x[i];
    }
    long long tot, minCoord = pow(10, 7);
    for(int xi = 1; xi <= 100; xi++){
        tot = 0;
        rep(i,n){
            tot += (x[i] - xi) * (x[i] - xi);
        }
        //cout << tot << endl;
        minCoord = min(minCoord, tot);
        //cout << minCoord << endl;
    }
    cout << minCoord << endl;
    return 0;
}

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

void bfs(const llong & N, llong cur, int use, llong & cnt) {
	if (cur > N) return;
	if (use == 0b111) cnt++;

	bfs(N, cur * 10 + 7, use | 0b100, cnt);
	bfs(N, cur * 10 + 5, use | 0b010, cnt);
	bfs(N, cur * 10 + 3, use | 0b001, cnt);
}

int main(void) {
	llong N, cnt = 0; cin >> N;

	bfs(N, 0, 0, cnt);
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int N, M;
int A[3];
vector<int> G[51];
bool used[51];
bool dp[101][51][51];  // a step, b start, c goal
 
int main(){
 
  cin>>N>>M;
  for(int i=0;i<3;i++)cin>>A[i];
  for(int i=0;i<M;i++){
    int f,t;
    cin>>f>>t;
    f--;t--;
    G[f].push_back(t);
  }
  int ite = 0;
 
  for(int i=0;i<N;i++)
    dp[0][i][i] = true;
  for(int i=1;i<101;i++){
    for(int j=0;j<N;j++){
      for(int k=0;k<N;k++){
        if(dp[i-1][j][k]){
          for(int to : G[k]){
            dp[i][j][to] = true;
          }
        }
      }
    }
  }
   
  used[N-1] = true;
  while(1){
    bool ok = false;
    vector<int> idx;
    for(int i=0;i<N;i++){
      if(used[i])continue;
      int cnt = 0;
      for(int j=0;j<3;j++){
        int a = A[j];
        bool t = false;
        for(int k=0;k<N;k++){
          if(dp[a][i][k] && used[k]){
            t = true;
          }
        }
        if(t){
          cnt++;
        }
      }
      // OK
      if(cnt == 3){
        ok=true;
        idx.push_back(i);
      }
    }
    if(ok){
      ite++;
      for(int i : idx){
        used[i]=true;
      }
      if(used[0]){
        cout<<ite<<endl;
        return 0;
      }
    }
    else{
      break;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
   
  return 0;
}

Measured memory_bytes: 3420
#include <bits/stdc++.h>
using namespace std ;
int n,t ;
int a[100005],ans=0,maxn=0,tot=0 ;
int main() {
    scanf("%d%d",&n,&t) ;
    for(register int i=1;i<=n;++i)scanf("%d",a+i);
    for(register int i=n;i>=1;--i){
        maxn=max(a[i],maxn);
        ans=max(maxn-a[i],ans);
    }
    maxn=0;
    for(register int i=n;i>=1;--i){
        maxn=max(a[i],maxn);
        if(maxn-a[i]==ans)++tot;
    }
    printf("%d",tot);
}

Measured memory_bytes: 640
import numpy as np

N,M = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
L = [1]*N

for _ in range(M):
    A,B = [int(i) for i in input().split()]
    A -= 1
    B -= 1
    if H[A] <= H[B]:
        L[A ] *= 0
    if H[B] <= H[A]:
        L[B] *= 0

L = np.array(L)

print(np.sum(L))


Measured memory_bytes: 38520
import numpy as np

N, T = map(int, input().split())
AB = []
for i in range(N):
  A, B = map(int, input().split())
  AB.append([A, B])

AB.sort()

dp = np.zeros(T, dtype=int)

ans = 0
for a, b in AB:
  ans = max(ans, dp[-1] + b)
  dp[a:] = np.maximum(dp[a:], dp[:-a] + b)

print(ans)

Measured memory_bytes: 22292
import java.util.Scanner;

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


for(int i=0;;i++){
    int m = sc.nextInt();
int f = sc.nextInt();
int r = sc.nextInt();
int sum = m+f;
    if(m==-1&&f==-1&&r==-1){
        break;
    }else if(m==-1||f==-1){
    System.out.printf("F\n");
}else if(sum<30){
    System.out.printf("F\n");
}else if(sum>=80){
    System.out.printf("A\n");
}else if(65<=sum&&sum<80){
    System.out.printf("B\n");
}else if(50<=sum&&sum<65){
    System.out.printf("C\n");
 } else if(30<=sum&&sum<50){
     if(r>=50){
        System.out.printf("C\n");
     }else{
        System.out.printf("D\n");
     }
    }
}
    sc.close();
}
}


Measured memory_bytes: 26172
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
#define pii pair<ll,ll>
#define x1 dlfjl
#define x2 dkfj
#define MOD 1000000007
#define y1 dskgj
#define y2 dskfj
#define SQ 320
#define N 8388607
typedef int ll;
using namespace std;
ll n,i,j,k,x,y,z,m,q,h,l,timer;
ll a[100500];
string s;
int main() {
    //freopen("input.txt","r",stdin);
    cin >> n >> m;
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
        {
            char c;
            cin >> c;
            a[c-'a']++;
        }
    ll k1 = 0, k2 = 0;
    for (i = 0; i < 26; i++)
        if (a[i]%4 == 1)
            k1++;
        else if (a[i]%4 == 2)
            k2++;
        else if (a[i]%4 == 3)
            k1++, k2++;
    if (n%2 && m%2)
    {
        if (k1 > 1 || k2 > (n+m-1)/2)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    } else
    if (n%2 == 0 && m%2 == 0)
    {
        if (k1 > 0 || k2 > 0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    } else
    {
        ll x;
        if (n%2 == 0)
            x = n/2;
        else
            x = m/2;
        if (k1 > 0 || k2 > x)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
count=0
f=0
for i in range(int(input())):
    a,b=map(int,input().split())
    if a==b:
        count+=1
    else:
        if count==3:
            f=1
            break
        else:
            count=0
if count>=3:
    f=1
if f==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62392
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    S = input()
    T = input()

    count = 0
    for i in range(len(S)):
        if not S[i] == T[i]:
            count += 1

    print(count)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 73556
//abc051_d.cpp
//Thu Mar 21 18:16:46 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
int check[100][100];
int dp[100][100];


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

	int hen[n][n];
	for (int i=0;i<n;i++){
		for (int j=0;j<n;j++){
			if (i==j){
				hen[i][j] = 0;
			}else{
				hen[i][j] = 2000000;
			}
		}
	}

	int start[m],goal[m],dist[m];
	for (int i=0;i<m;i++){
		int a,b,c;
		cin >> a >> b >> c;
		hen[a-1][b-1] = c;
		hen[b-1][a-1] = c;
		start[i] = a-1;
		goal[i] = b-1;
		dist[i] = c;
	}

	for (int i=0;i<n;i++){
		for (int x=0;x<n;x++){
			for (int y=0;y<n;y++){
				hen[x][y] = min(hen[x][y],hen[x][i]+hen[i][y]);
			}
		}
	}

	int ans = m;
	for (int x=0;x<m;x++){
		int s = start[x];
		int g = goal[x];
		int flag = 0;
		for (int i=0;i<n;i++){
			for (int j=0;j<n;j++){
				int test = hen[i][j];
				if (test == hen[i][s]+dist[x]+hen[g][j]){
					ans--;
					flag++;
					break;
				}
			}
			if (flag){
				break;
			}
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

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

void Main() {
  int N;
  cin >> N;

  int A[N];
  memset(A, 0, sizeof(A));
  for (int i = 1; i < N; i++) {
    int tmp;
    cin >> tmp;
    A[tmp - 1]++;
  }

  for (int i = 0; i < N; i++) {
    cout << A[i] << endl;
  }
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 4420
#include <cstdio>
int m,M,X,Y,x,y,i,j;
main(){ while(scanf("%d%d",&x,&y),x||y){
m=x*x+y*y,M=90000;
for(i=150;i;i--)for(j=i+1;j<=150;j++){y=i*i+j*j;if(m==y&&x<i)M=y,X=i,Y=j;else if(m<y&&M>=y)M=y,X=i,Y=j;}
printf("%d %d\n",X,Y);}return 0;}

Measured memory_bytes: 1028
v, e = map(int, input().split())
a_lst = input().split()
edges = [[] for _ in range(v)]
for _ in range(e):
    s, t = map(int, input().split())
    edges[s].append(t)
    edges[t].append(s)

for i in range(v):
    if "a" <= a_lst[i] <= "z": continue
    lst = {i for i in range(26)}
    for fr in edges[i]:
        lst.discard(ord(a_lst[fr]) - ord("a"))
    a_lst[i] = chr(min(lst) + ord("a"))

print("".join(a_lst))


Measured memory_bytes: 31668