akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<math.h>
#include<string.h>
int main( )
{ 
	int i;
	int a[5]={2,4,5,7,9};
	int b[5]={0,1,6,8};
	int c=3;
	int n;
	scanf("%d",&n);
	int x;
	x=n%10;
	for(i=0;i<5;i++)
	{
		if(a[i]==x)
		{printf("hon");return 0;}
	}
	for(i=0;i<4;i++)
	{
		if(b[i]==x)
		{printf("pon");return 0;}
	}
	if(x==c)
	{printf("bon");return 0;}
}


Measured memory_bytes: 1724
#define NUM 100
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int n,i;
    int box[NUM];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&box[i]);
    }for(i=n-1;i>=0;i--){
        printf("%d",box[i]);
        if(i!=0){
            printf(" ");
        }
    }printf("\n");
    
    
    
    return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long

bool is_palindrome(string s)
{
  string q(s.rbegin(), s.rend());
  if (q==s)
    return true;
  else
    return false;
}

int main()
{
  IOS;
  string s;
  cin >> s;
  int n=s.length();
  if (is_palindrome(s) && is_palindrome(s.substr(0, (n - 1) / 2)) && is_palindrome(s.substr((n + 1) / 2)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  int A, B;
  CIN(A >> B);

  if (A <= B * 2) {
    COUT(0);
  } else {
    COUT(A - B * 2);
  }

  return 0;
}


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

using namespace std;

typedef long long int ll;

const int N = 2e6 + 5;
const int mod = 1e9 + 7;

vector < ll > fact (N);

ll pwr (ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}

ll inv (ll a) {
  return pwr (a, mod - 2);
}

ll nCr (int n, int r) {
  return ((((fact[n] * inv (fact[r])) % mod) * inv (fact[n - r])) % mod);
}

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

  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = (i * fact[i - 1]) % mod;

  int k;
  string s;
  cin >> k >> s;
  int n = s.length();

  ll ans = 0;
  for (int x = 0; x <= k; x++) {
    ans = (ans + ((((pwr (26, x) * pwr (25, k - x)) % mod) * nCr (k - x + n - 1, n - 1)) % mod)) % mod;
  }

  cout << ans << '\n';
}


Measured memory_bytes: 19844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
#define arrlen(arr) (sizeof(arr)/sizeof(arr[0]))
#define Sort(arr) sort(arr, arr+arrlen(arr))
#define For(i,s,n) for(int i=s;i<n;i++)

	
int main(){
	int N;
	cin >> N;
	cout << 180*N-360;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	char a[11];
	char b[11];
	char c[11];
	cin >> a >> b >> c;
	if (a[0] >= 'a' && a[0] <= 'z')
		a[0] -=32;
	 if (b[0] >= 'a' && a[0] <= 'z')
		b[0] -= 32;
	 if (c[0] >= 'a' && a[0] <= 'z')
		c[0] -= 32;

	cout << a[0] << b[0] << c[0];

}

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

#define forn(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
ll dp[100005][105];
const ll h=1e9L +7;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);	
        ll n,k;
        cin>>n>>k;
        ll x;cin>>x;
        for(int j=0;j<x+1;j++){
            dp[j][1]=1;
        }
        ll sum=x;
        for(int j=1;j<=n;j++)dp[0][j]=1;
        for(int i=2;i<n+1;i++){
            ll a;cin>>a;
            sum=min(k,sum+a);
            for(int j=1;j<a+1;j++){
                dp[j][i]=(dp[j-1][i]+dp[j][i-1]+h)%h;
            }
            for(int j=a+1;j<sum+1;j++){
                dp[j][i]=(dp[j-1][i]+dp[j][i-1]-dp[j-a-1][i-1]+h)%h;
            }
        }
        //for(int i=0;i<=k;i++){
            //for(int j=0;j<=n;j++){
                //cout<<dp[i][j]<<" ";
            //}
            //cout<<endl;
        //}
        cout<<dp[k][n]<<endl;
                
}


Measured memory_bytes: 82304
import java.io.*;

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

		BufferedReader br =
		new BufferedReader( new InputStreamReader(System.in));

		String str = br.readLine();
		
		int x=Integer.parseInt(str);

		System.out.println(x*x*x);
	}
}

Measured memory_bytes: 24184
from collections import Counter

N = int(input())
S = [input() for _ in range(N)]

M = int(input())
T = [input() for _ in range(M)]

s_counter = Counter(S)
t_counter = Counter(T)

result = 0

for k, v in s_counter.items():
    result = max(result, v - (t_counter[k] if t_counter[k] else 0))

print(result if result > 0 else 0)


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


map<long long, long long> prime_factor_pi(long long n) {
	map<long long, long long> res;
	for (long long i = 2; i <= n; i++) {
		ll nn = i;
		for (long long j = 2; j * j <= i; j++) {
			while (nn % j == 0) {
				++res[j];
				nn /= j;
			}
		}
		if (nn != 1) res[nn]++;
	}
	
	return res;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	map<long long, long long> m = prime_factor_pi(N);
	ll res = 0, n2 = 0, n4 = 0, n14 = 0, n24 = 0, n74 = 0;
	for(auto x : m) {
		// cout << x.first << " " << x.second << endl;
        if (2 <= x.second) n2++;
		if (4 <= x.second) n4++;
		if (14 <= x.second) n14++;
		if (24 <= x.second) n24++;
		if (74 <= x.second) n74++;
    }
	res += max(0LL, n2-2)*max(0LL, n4*(n4-1)/2); // 3*5*5
	res += max(0LL, n4-1)*n14; // 5*15
	res += max(0LL, n2-1)*n24; // 3*25
	res += n74; // 75
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class MyUtil {
	public BufferedReader br;
	public MyUtil() {
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	public long getLong() throws IOException {
		return Long.valueOf(br.readLine());
	}

	public int getInt() throws IOException {
		return Integer.valueOf(br.readLine());
	}

	public int[] splitIntArray(int N, int offset) throws IOException {
		int[] ret = new int[N + offset];
		String[] s = br.readLine().split(" ");
		for (int i=0; i < N; ++i) {
			ret[i + offset] = Integer.valueOf(s[i]);
		}
		return ret;
	}

	public int[] getIntArray(int N) throws IOException {
		int[] ret = new int[N];
		for (int i=0; i < N; ++i) {
			ret[i] = Integer.valueOf(br.readLine());
		}
		return ret;
	}

	public String getString() throws IOException {
		return br.readLine();
	}

	public String[] getSplitString(String delim) throws IOException {
		return br.readLine().split(delim);
	}

	public String[] getStringArray(int N) throws IOException {
		String[] ret = new String[N];
		for (int i=0; i < N; ++i) {
			ret[i] = br.readLine();
		}
		return ret;
	}
}

public class Main {
	public static void main(String[] args) throws IOException {
		new ABC125().c();
	}
}

class ABC125 {
	int gcd(int x, int y) {
		if (x < y) {
			int t = x;
			x = y;
			y = t;
		}
		if (y == 0) {
			return x;
		}
		return gcd(y, x % y);
	}

	void c() throws IOException {
		MyUtil mu = new MyUtil();
		int N = mu.getInt();
		int[] A = mu.splitIntArray(N, 1);
		int[] L = new int[N + 2];
		int[] R = new int[N + 2];
		for (int i=1; i <= N; ++i) {
			L[i] = gcd(L[i - 1], A[i]);
		}
		for (int i=N; i >= 1; --i) {
			R[i] = gcd(R[i + 1], A[i]);
		}
		int ans = 1;
		for (int i=1; i <= N; ++i) {
			int g =gcd(L[i - 1], R[i + 1]);
			ans = Math.max(ans, g);
		}
		System.out.println(ans);
	}
}

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

int main() {
  int n;
  cin>>n;
  vector<int>sum(26,INT_MAX);
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    vector<int> a(26,0);
    for(int j=0;j<s.size();j++){
      for(char c='a';c<='z';c++){
        if(s[j]==c){
          int b=c-'a';
          a[b]++;
          break;
        }
      }
    }
    for(int j=0;j<26;j++){
      sum[j]=min(sum[j],a[j]);
    }
  }
  for(int i=0;i<26;i++){
    if(sum[i]!=0){
      for(int j=0;j<sum[i];j++){
        char c=i+'a';
        cout<<(char) c;
      }
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int ll
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define vi vector<int>
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int dp[4];
int inf = 1e10;
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	rep(i,4){
		dp[i] = -inf;
	}
	int x[n][2];
	rep(i,n){
		cin>>x[i][0]>>x[i][1];
	}
	int ans = 0;
	rep(i,n){
		rep(mask,(1<<2)){
			int temp = 0;
			rep(j,2){
				if((1<<j) & (mask)){
					temp -= x[i][j];
				}
				else{
					temp += x[i][j];
				}
			}
			dp[mask] = max(dp[mask],temp);
		}
		rep(mask,(1<<2)){
			int mask2 = 3 ^ mask;
			ans = max(ans,dp[mask] + dp[mask2]);
		}
		// dp[0] = max(dp[0],x[i]+y[i]);
		// dp[1] = max(dp[0])
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 6740
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);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--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
    int h,w;
    cin>>h>>w;
    int a[h][w];
    REP(i,h)
    {
        REP(j,w)
        {
            char c;
            cin>>c;
            if(c=='.')
            a[i][j]=0;
            else a[i][j]=1;
        }
    }
    ll dp[h+1][w+1]={{0}};
    for(int i=0;i<h;i++)
    {
        for(int j=0;j<w;j++)
        {
            if(i==0 && j==0)
            dp[i][j]=1;
            else if(i==0)
            {
                if(a[i][j])
                dp[i][j]=0;
                else dp[i][j]=dp[i][j-1];
            }
            else if(j==0)
            {
                if(a[i][j])
                dp[i][j]=0;
                else dp[i][j]=dp[i-1][j];
                
            }
            else
            {
                if(a[i][j])
                dp[i][j]=0;
                else dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
            }   
        }
    }
    /*REP(i,h)
    {
        REP(j,w)
        cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
    cout<<dp[h-1][w-1];
  }  
  return 0;
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

constexpr int MAXN = 21;
constexpr int MOD = 1e9 + 7;

int n;
int a[MAXN][MAXN];
int dp[1 << MAXN][MAXN + 1];

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

    scanf(" %d", &n);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            scanf(" %d", &a[i][j]);
        }
    }

    // dp[mask][i] = number of ways to pair up the first i rows with the columns in mask
    // iterate over all j. if you can pair with j and j is in the mask, then add dp[mask ^ (1 << j)][i - 1]
    dp[0][0] = 1;
    for (int mask = 1; mask < (1 << n); ++mask) {
        for (int j = 0; j < n; ++j) {
            if (!(mask & (1 << j)))
                continue;
            for (int i = 0; i < n; ++i) {
                if (a[j][i]) {
                    dp[mask][i + 1] += dp[mask ^ (1 << j)][i];
                    if (dp[mask][i + 1] >= MOD)
                        dp[mask][i + 1] -= MOD;
                }
            }
        }
    }

    cout << dp[(1 << n) - 1][n] << '\n';
    
    return 0;
}


Measured memory_bytes: 180480
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	long long x;
	cin >> x;

	long long ans = x / 11;
	int a = 6;
	long long s = ans * 11;
	ans <<= 1;
	while (s < x) {
		s += a;
		if (a == 6) {
			a = 5;
		} else {
			a = 6;
		}

		++ans;
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a;
  unsigned char *s = new unsigned char[101];
  unsigned char *t = new unsigned char[101];
  unsigned char *r = new unsigned char[201];
  cin >> a >> s >> t;
  for (int i = 0; i < a; i++){
    r[2*i] = s[i];
    r[2*i+1] = t[i];
  }
  cout << r;
  delete [] s;
  delete [] t;
  delete [] r;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct Edge{
	int v,next;
}edge[100001];
int head[100001],tot=0;
void addedge(int u,int v)
{
	tot++;
	edge[tot].v=v;
	edge[tot].next=head[u];
	head[u]=tot;
}
int mx[100001];
void dfs(int u)
{
	if(mx[u])return;
	mx[u]=1;
	for(int i=head[u];i;i=edge[i].next)
	{
		int v=edge[i].v;
		dfs(v);
		mx[u]=max(mx[u],mx[v]+1);
	}
}
int main()
{
	int n,m;cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int u,v;cin>>u>>v;
		addedge(u,v);
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		if(!mx[i])dfs(i);
		ans=max(ans,mx[i]);
	}
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 7164
#include<iostream>
#include <algorithm>
#include<string>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;
int main() {
    int  a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(a-c)*(b-d)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

const ll MODULO = 998244353L;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

ll mod_pow(ll x, ll n, ll modval) {
    if (n == 0) {
        return 1;
    }
    ll res = mod_pow(x * x % modval, n / 2, modval);
    if (n & 1) {
        res = res * x % modval;
    }
    return res;
}
ll pow(ll x, ll n) {
    return mod_pow(x, n, MODULO);
}
ll mod(ll n) {
    return n % MODULO;
}

const ll COMBMAX = 200000;
ll fac[COMBMAX], finv[COMBMAX], inv[COMBMAX];
void combination_init() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < COMBMAX; i++) {
        fac[i] = fac[i - 1] * i % MODULO;
        inv[i] = MODULO - inv[MODULO % i] * (MODULO / i) % MODULO;
        finv[i] = finv[i - 1] * inv[i] % MODULO;
    }
}
ll combination(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MODULO) % MODULO;
}

int main() {
    ll N, M, K;
    cin >> N >> M >> K;

    combination_init();
    ll result = 0;
    for (ll j = 0; j <= K; j++) {
        result = mod(result + mod(combination(N - 1, j) * mod(M * pow(M - 1, N - j - 1))));
    }
    print(result);
}


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

int main()
{
	int n, k;
	cin >> n >> k;
	
	int ans = 0;
	while (n > 0) {
		ans++;
		n /= k;
	}

	cout << ans << endl;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(begin, end) for(auto itr = (begin); itr != (end); itr++)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll W, H, x, y;
ll ret = 0;

void input() {
  IN(W);
  IN(H);
  IN(x);
  IN(y);
}

void solve() {
  bool flg = (x == W/2.0) && (y == H/2.0);
  double s = (double)W * (double)H / 2.0;
  cout << setprecision(10) << s << " " << (flg?1:0) << endl;
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
n = int(input())
w = [0]*n
r = [0]*n
for i in range(n):
    r[i] = input()
    w[i] = list(r[i])
    
ans = 1
for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
        ans = 0
        break
q = set(r)
if len(q) != n:
    ans = 0
if ans == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int N, K;
    int A[105] = {0};

    cin >> N >> K;

    for (int i = 0; i < K; i++) {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++) {
            int a;
            cin >> a;
            A[a] = 1;
        }
    }
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (A[i] == 0) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> vec(N);
  int ALL = 0;
  int ans = 0;
  for(int i = 0;i < N;i++){
    cin >> vec[i];
    ALL += vec[i];
  }
  for(int i = 0;i < N;i++){
    if(vec[i] * 4 * M >= ALL){
      ans++;
    }
  }
  if(ans >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int>v1,v2;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int u,v;
        cin>>u>>v;
        v1.push_back(u+v);
        v2.push_back(u-v);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    cout<<max(v1[n-1]-v1[0],v2[n-1]-v2[0])<<endl;
}

Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
int main() {
 int r,d,x;
 cin >> r >> d >> x;
 ll ans;
 ans = r*x-d;

rep (i,10){
  cout << ans << endl;
  ans=ans*r-d;

}
 
 }


 
 






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

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

	int a, b, c;
	cin >> a >> b >> c;
	int count;
	count = 0;
	while (1)
	{
		if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
		{
			if (a == b && b == c)
			{
				count = -1;
				break;
			}
			else
			{
				count++;
				int ha, hb, hc;
				ha = a / 2;
				hb = b / 2;
				hc = c / 2;
				a = hb + hc;
				b = ha + hc;
				c = ha + hb;
			}
		}
		else
			break;
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#define N 10000000
int ans[N],w,p;

void rr(int x)
{
  ans[p]=x;
  p++;
  if(p>=N)
  {
    p=0;
  }
}

int pp()
{

  int d=ans[w];
  w++;
  if(w>=N) w=0;
  return d;
}

int main()
{

  int m,q,i,sum;
  int c[m];
  scanf("%d%d",&m,&q);
  char cod[m][10];

    w=p=0;

  for(i=0;i<m;i++)
  {
    scanf("%s %d",cod[i],&c[i]);
    rr(i);
  }

sum=0;

  while(w!=p)
  {
    int x=pp();
    if(q<c[x])
    {
      sum+=q;
      c[x]-=q;
      rr(x);
    }
    else
    {
      sum+=c[x];
      printf("%s %d\n",cod[x],sum);
    }
  }
  return 0;
}



Measured memory_bytes: 3172
# ヒープに要素を追加、一番でかいのを取り出すという操作を最大3000回やるやり方
# これもなかなか早い
# ヒープは追加も要素の取り出しもO(log n)で住むので、
# 計算オーダーはO(K log n)で済む(nはヒープの要素数)らしいが
# not in があるのでO(n K log n)では？
# pythonのヒープは使い方に癖があるのでこの機会に習得しよう
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = read_ints()
B = read_ints()
C = read_ints()

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

heap = []  # ヒープといっても順序を工夫したただのリスト

from heapq import heapify, heappop, heappush, heappushpop
heappush(heap, (-(A[0] + B[0] + C[0]), 0, 0, 0))

ans = []
for k_th in range(1, K+1):
    heap_max, i, j, k = heappop(heap)
    # print(heap_max)
    ans.append(-heap_max)
    for di, dj, dk in zip([1, 0, 0], [0, 1, 0], [0, 0, 1]):
        i_new, j_new, k_new = i + di, j + dj, k + dk
        if i_new >= X or j_new >= Y or k_new >= Z:
            continue
        tmp = (-(A[i_new] + B[j_new] + C[k_new]), i_new, j_new, k_new)
        if tmp in heap:  # ここが計算量がおおい
            continue
        heappush(heap, tmp)
        # print(heap)


print(*ans, sep='\n')


Measured memory_bytes: 4116
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！

        Scanner sc = new Scanner(System.in);
        String answer = sc.next();
        if (answer.matches("((dream)|(dreamer)|(erase)|(eraser))*")) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 37716
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n);
#define REPEAT(i, k, n)     for(int i = (k); i < (k+n); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); ++i)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)          (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)          (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define mp                  make_pair
#define pb                  push_back

typedef long long ll;
typedef unsigned long long ull;

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif


int c[] = {1, 4, 1, 4, 1, 2, 1, 2 };
void solve(int n[8]){
    int mini = -1;
    int min = 100000;
    REP(i,8){
        int p = 0;
        REP(j,8){
            if(n[j] > c[(i+j)%8]){
                p += n[j] - c[(i+j)%8];
            }
        }
        bool flag = false;
        if(min == p){
            REP(j,8){
                if(c[(mini+j)%8] < c[(i+j)%8]){ flag = false; break; }
                if(c[(mini+j)%8] > c[(i+j)%8]){ flag = true; break; }
            }
        }
        if(flag || min > p){
            min = p;
            mini = i;
        }
    }
    cout << c[mini];
    REP(j,7) cout << " " << c[(mini+j+1)%8];
    cout << endl;
}

int main(){
    int n[8];
    while(1){
        REP(i,8){
            if((cin >> n[i]) == NULL){
                return 0;
            }
        }
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 1160
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int n,ans;

signed main(){
	read(n);
	for(int l=1,r;l<=n;l=r+1){
		r=n/(n/l);
		int x=n/l;
		if(n%x==0&&n/x-1>=l&&n/x-1<=r) ans+=n/x-1;
	}
	write(ans);
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int n;
char a[101],b[101];
int main()
{
	cin>>n;
	scanf("%s",a);
	scanf("%s",b);
	for(int i=0;i<n;i++)
	{
		cout<<a[i];
		cout<<b[i];
	}
	
	return 0;
}

Measured memory_bytes: 256
n = int(input())
xy = []
for i in range(n):
    a = int(input())
    l = []
    for j in range(a):
        x, y = map(int, input().split())
        l.append((x, y))
    xy.append(l)

# ビット全探索
bit = 0
ans = 0
for X in range(2 ** n):
    # 1010など
    flag = False
    count = 0
    for num in range(n):
        f = True
        if X & (2 ** num) >= 1:
            for x, y in xy[num]:
                t = 1 if X & 2 ** (x-1) >= 1 else 0
                if t != y:
                    f = False
                    break
            if f == False:
                count = 0
                break
            count += 1
    ans = max(count, ans)
print(ans)

Measured memory_bytes: 47088
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> p(m);
  rep(i, m) cin >> p[i].first >> p[i].second;

  vector<int> ans(n);
  rep(i, m) {
    ans[p[i].first - 1]++;
    ans[p[i].second - 1]++;
  }
  rep(i, n) cout << ans[i] << endl;


  
  return 0;
}

Measured memory_bytes: 256
import math

n,m = map(int,input().split())
s = list(map(int,input().split()))
 
votes = 0
for i in range(n):
    votes += s[i]
 
s.sort(reverse=True)
 
for i in range(m):
    if s[i] < math.ceil(votes/(4*m)):
        print("No")
        exit()
 
print("Yes")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int N; cin >> N; int p[N], q[N], t; bool tt=false;
  for(int i=0; i<N; i++) {cin >> p[i]; q[i] = p[i];}
  
  sort(q, q+N); tt=true;
  //for(int i=0; i<N; i++) cout << p[i] << " "; cout << endl;
  //for(int i=0; i<N; i++) cout << q[i] << " "; cout << endl;
  for(int i=0; i<N; i++) if (p[i] != q[i]) tt=false;
  if (tt){
    cout << "YES" << endl;
    return 0;
  }
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      t=p[i]; p[i]=p[j]; p[j]=t; tt=true;
      for(int k=0; k<N; k++){
        if (p[k] != q[k]) tt=false;
      }
      t=p[i]; p[i]=p[j]; p[j]=t;
      if (tt) break;
    }
    if (tt) break;
  }
  cout << ((tt)? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		int[] counts = new int[n + 1];
		for (int i = 2; i <= n; i++) {
		    counts[i] = counts[i - 1];
		    if (arr[i - 2] == 'A' && arr[i - 1] == 'C') {
		        counts[i]++;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
		    int count = - counts[sc.nextInt()] + counts[sc.nextInt()];
		    sb.append(count).append("\n");
		}
		System.out.print(sb);
   }
}


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

using namespace std;
string t;
string ans;

void dfs(int i,string s,int n);
void solve();

int main(void){
    cin >> t;
    solve();
    return 0;
}

void dfs(int i, string s, int n){
      if(i==3){
            if(n==7){
                  ans=s+"=7";
            }
            return ;
      }
      dfs(i+1,s + "+" + t[i + 1],n + (t[i + 1] - '0'));
      dfs(i+1,s + "-" + t[i + 1],n - (t[i + 1] - '0'));
 
}

void solve(){
    dfs(0,t.substr(0,1),t[0]-'0');
    cout << ans << endl;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int n;
vector<int> V[MC];

int main(){
	cin >> n;
	repp(i,1,n){
		int a,b; cin >> a >> b;
		V[a].PB(b);
		V[b].PB(a);
	}
	if(n == 2){
		cout << "1 2" << endl;
		return 0;
	}
	if(n == 3){
		cout << "1 2 3" << endl;
		return 0;
	}
	vector<int> r;
	bool b = 0;
	vector<int> c(n+1,0);
	repm(i,n,0){
		int z = 0;
		for(auto u : V[i]){
			if((int)V[u].size() > 1) ++z;
			else ++c[i];
		}
		if(z > 2) b = 1;
		else if(z < 2 && (int)V[i].size() > 1) r.PB(i);
	}
	if(b) return cout << -1 << endl , 0;
	vector<int> ans(n);
	ans[0] = n+1;
	for(auto _r : r){
		vector<int> q(n);
		int x = _r;
		int d = 1;
		--c[_r];
		q[0] = 0;
		vector<int> b(n+1,0);
		while(d < n){
			if(c[x] < 0) break;
			repp(i,0,c[x]){
				q[d+1+i] = d+i;
			}
			q[d] = d+c[x];
			d += c[x]+1;
			b[x] = 1;
			for(auto u : V[x]){
				if(b[u] == 0 && (int)V[u].size() > 1){
					x = u;
					break;
				}
			}
		}
		++c[_r];
		vector<int> p(n);
		repp(i,0,n) p[q[i]] = i+1;
		swap(p[n-2],p[n-1]);
		repp(i,0,n){
			if(ans[i] == p[i]) continue;
			if(ans[i] > p[i]) swap(ans,p);
			break;
		}
	}
	repp(i,0,n) cout << ans[i] << ' ';
	cout << endl;
	return 0;
}


Measured memory_bytes: 8060
#!/usr/bin/env python3
import sys


def solve(N: int, A: int, B: int):
    if A > B:
        print(0)
        return
    
    if N == 1:
        if A==B:
            print(1)
        else:
            print(0)
        return
    
    min_sum = A*(N-1)+B
    max_sum = A+B*(N-1)
    print(max_sum-min_sum+1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(N, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
n = int(input())
ab = set(tuple(map(int, input().split())) for _ in range(n))
cd = sorted(tuple(map(int, input().split())) for _ in range(n))

ab |= {(-1, -1)}
for c, d in cd:
    tmp = max((b, a) for a, b in ab if (a < c and b < d))[::-1]
    if tmp != (-1, -1):
        ab.remove(tmp)
print(n - (len(ab) - 1))


Measured memory_bytes: 66564
#include <algorithm>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  map<int, int> A;
  for (int i = 0; i < N; ++i) {
    int index;
    cin >> index;

    auto itr = A.find(index);
    if (itr != A.end()) {
      A[index] += 1;
    } else {
      A[index] = 1;
    }
  }
  vector<int> num_value;
  for (auto x : A) {
    num_value.push_back(x.second);
  }
  if (num_value.size() <= K) {
    cout << 0 << endl;
    return 0;
  }
  // 削除が必要
  sort(num_value.begin(), num_value.end());
  int ans = 0;
  for (int i = 0; i < num_value.size() - K; ++i) {
    ans += num_value[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
 
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
#define int ll
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);

template<typename A> ostream& operator<<(ostream&,vector<A>&);
 
const int N=1000002;

void solve(){
	string s,t;
	cin>>s>>t;
	set<char>sx;
	for(auto i:t){
		sx.insert(i);
	}
	for(int i=0;i<s.length();i++){
		if(sx.find(s[i])!=sx.end()){
			sx.erase(s[i]);
		}
			}
    if(sx.size()){
		cout<<-1;
		return;
	}
	vector<int>ans[26];
	for(int i=0;i<s.length();i++){
		ans[s[i]-'a'].pb(i);
	}
	int prev=-1;
	ll ab=0;
	for(int i=0;i<t.length();i++){
		if((upper_bound(all(ans[t[i]-'a']),prev)-ans[t[i]-'a'].begin())==ans[t[i]-'a'].size()){
			ab+=(int)s.length();
			prev=ans[t[i]-'a'][0];
		}
		else{
			prev=*upper_bound(all(ans[t[i]-'a']),prev);
		}
			
		
	}
	cout<<ab+prev+1;
}

 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
	    output<<i<<' ';
	return output;
}


Measured memory_bytes: 1736
#include<cmath>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const double pi=4*atan(1.0);
const int N = 1e5+5;
const ll mod = 998244353;
set<string>s;
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        string x;
        cin>>x;
        s.insert(x);
    }
    printf("%d\n",s.size());
    return 0;
}


Measured memory_bytes: 19308
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
string s;
int ans=0;
signed main(){
    cin>>s;
    int l=s.size();
    char base=s[0];
    rep(i,l){
        if(i%2){
            if(s[i]==s[0])ans++;
        }
        else{
            if(s[i]!=s[0])ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[][] e = new int[n][n];
        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(sc.next()) - 1;
            int b = Integer.parseInt(sc.next()) - 1;
            e[a][b] = 1;
            e[b][a] = 1;
        }
        boolean[] visited = new boolean[n];
        visited[0] = true;
        System.out.println(dfs(0, n, visited, e));
    }

    private static int dfs(int v, int n, boolean[] visited, int[][] e) {
        boolean allVisited = true;
        for (int i = 0; i < n; i++) {
            if (!visited[i]) {
                allVisited = false;
            }
        }
        if (allVisited) {
            return 1;
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (e[v][i] == 0) {
                continue;
            }
            if (visited[i]) {
                continue;
            }
            visited[i] = true;
            ans += dfs(i, n, visited, e);
            visited[i] = false;
        }
        return ans;
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std ;
bool check(string s)
{
  string s1 = s ;
//  cout << s << endl ;
  reverse(s1.begin() , s1.end()) ;
  return s1 == s ;
}
int main()
{
  string s ;
  cin >> s ;
  if(check(s) && check(s.substr(0 , s.size() / 2)) && check(s.substr((s.size() / 2 + 1))))
   puts("Yes") ;
  else puts("No") ;
  return 0 ;
}


Measured memory_bytes: 256
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int maxn=105000;
	const int inf=0x3f3f3f3f;
	ll w[105];
	ll v[105];
	ll dp[105][maxn];
	ll n,m;
	int main(){
		IOS
		cin>>n>>m;
		for(int i=1;i<=n;i++)
			cin>>w[i]>>v[i];
		for(int i=2;i<=n+1;i++){
			for(int j=0;j<=m;j++){
				dp[i][j]=dp[i-1][j];
				if(j+w[i-1]<=m){
					dp[i][j]=max(dp[i][j],dp[i-1][j+w[i-1]]+v[i-1]);
				}
			}
				
					
		}
		ll ans=-1;
		for(int j=0;j<=m;j++)
			ans=max(ans,dp[n+1][j]);
		cout<<ans<<endl;
	}

Measured memory_bytes: 81984
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

void eratosthenes(vector<int> &prime, int N) {
    vector<int> eratos(N + 1, 1);
    eratos[0] = 0;
    eratos[1] = 0;
    for (int i = 2; i <= N; i++) {
        if (eratos[i] == 0)
            continue;
        prime.push_back(i);
        for (int j = i; i + j <= N; j += i) {
            eratos[i + j] = 0;
        }
    }
}

signed main() {
    N = 1;
    int tmp = 1;
    cin >> X;
    while (N - 1 < X) {
        tmp++;
        N *= tmp;
    }
    vector<int> prime;
    eratosthenes(prime, N);
    cout << *lower_bound(ALL(prime), X) << endl;
}

Measured memory_bytes: 1920
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
using P = pair<ll, ll>;

template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}

const ll MOD = 1000000007;
const int INF = 1<<29;

int main(){
  string S; cin >> S;
  int N = S.length();
  bool ans = true;
  rep(i, N){
    if (i % 2 == 0){
      if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') ans = true;
      else {ans = false; break;}
    }else{
      if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') ans = true;
      else {ans = false; break;}
    }
  }
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define loop(i,n) for(int i=0;i<(int)n;i++)

using namespace std;

int main()
{
long int n;
long long int x;
long long int ans=0;
cin>>n>>x;


long long int e[n];

loop(i,n) cin>>e[i];

for(int i=0;i<n-1;i++)
	{
	    if(e[i]>x){
            ans+=e[i]-x;
            e[i]=x;
	    }

		if(e[i]+e[i+1]>x){

            ans+=e[i]+e[i+1]-x;
            e[i+1]=x-e[i];
		}


	}

cout<<ans<<endl;
}


Measured memory_bytes: 4400
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
	int len,bj[5]={0};
    string a;
    cin>>a;
    len=a.length();
    for(int i=0;i<len;i++)
    {
    	if(a[i]=='N')bj[1]=1;
    	if(a[i]=='W')bj[2]=1;
    	if(a[i]=='S')bj[3]=1;
    	if(a[i]=='E')bj[4]=1;
	}
	if(bj[1]==bj[3]&&bj[2]==bj[4])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n, i, j, temp;
  char s[101], t[101];
  gets(s);
  gets(t);  
  n = strlen(s);
  if(strcmp(s,t)==0)
  {
      printf("Yes\n");
      return 0;
  }
  for(i=1; i<n; i++)
  {
      temp = s[0];
      for(j=0; j<n-1; j++)
      {
          s[j] = s[j+1];
      }
      s[j] = temp;
      
      if(strcmp(s,t)==0)
      {
          printf("Yes\n");
          return 0;
      }
  }
  printf("No\n");
  
  return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {

  static Scanner sc = new Scanner(System.in);

  static int N;

  public static void main(String[] args) {

    String S = sc.next();
    N = Integer.parseInt(S);

    int ans = 0;

    for (int i=3; i<=S.length()-1; i++) {
      ans += (int) Math.pow(3, i) - 3 * (int) Math.pow(2, i) + 3;
    }

    ans += f(3 * (int)Math.pow(10, S.length()-1), S.length()  - 2);
    ans += f(5 * (int)Math.pow(10, S.length()-1), S.length()  - 2);
    ans += f(7 * (int)Math.pow(10, S.length()-1), S.length()  - 2);

    System.out.println(ans);

  }

  static int f(int a, int m) {
    if (m >= 0) {
      return f(a + 3 * (int)Math.pow(10, m), m-1) +
              f(a + 5 * (int)Math.pow(10, m), m-1) +
              f(a + 7 * (int)Math.pow(10, m), m-1);
    } else {
      String s = Integer.toString(a);
      if (s.indexOf("3") != -1 && s.indexOf("5") != -1 && s.indexOf("7") != -1 && a <= N) {
        return 1;
      } else {
        return 0;
      }
    }
  }
  
}


Measured memory_bytes: 25172
#include <iostream>
using namespace std;
int h, w, d;
char c[500][500], a[2][2]={{'R', 'Y'}, {'G', 'B'}};
void f(int y, int x, char z){
    for(int i=0;i<d;i++){
        int s=i;
        if(i>=d/2)s=d-i-1;
        for(int j=-s;j<=s;j++){
            int ny=y+j, nx=x+i;
            if(ny>=0&&ny<h&&nx>=0&&nx<w){
                c[ny][nx]=z;
            }
        }
    }
}
int main(void){
    cin>>h>>w>>d;
    if(d%2==1){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cout<<a[(i+j)%2][0];
            }
            cout<<endl;
        }
        return 0;
    }
    
    for(int k=0;k<2;k++){
        for(int i=-d;i<=h+d;i+=d){
            for(int j=-d;j<=w+d;j+=d){
                f(i+k*d/2, j+k*d/2, a[k][((i+d)/d+(j+d)/d)%2]);
            }
        }
    }
    
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<c[i][j];
        }
        cout<<endl;
    }
    
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
main()
{
    int n, m;
    cin >> n >> m;
    vector<int> v[15];
    int w[15];
    rep(i, m)
    {
        int a;
        cin >> a;
        rep(j, a)
        {
            int x;
            cin >> x;
            x--;
            v[i].push_back(x);
        }
    }
    rep(i, m) cin >> w[i];
    int ans = 0;
    rep(i, (1 << n))
    {
        rep(j, m)
        {
            int x = 0;
            rep(k, v[j].size())
            {
                int a = v[j][k];
                if ((i >> a) & 1)
                    x ^= 1;
            }
            if (x != w[j])
                goto f;
        }
        ans++;
    f:;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000002


int main(){
	
	int X;
	cin>>X;
	
	cout<<10-(X/200)<<endl;
	
	return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int ans=0;
    String s= sc.next();
    for(int i=0; i<s.length(); i++){
      if('+' == s.charAt(i)){
        ans++;
      }
      else{
        ans--;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844