akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

type pair struct {
	x, y int
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	_, _, M := getInt(), getInt(), getInt()
	h := make(map[int]int)
	w := make(map[int]int)
	xy := make(map[pair]int)
	for i := 0; i < M; i++ {
		hh, ww := getInt(), getInt()
		h[hh]++
		w[ww]++
		xy[pair{hh, ww}]++
	}
	maxH := 0
	maxW := 0
	hpos := make([]int, 0, 300000)
	wpos := make([]int, 0, 300000)
	for i, n := range h {
		if maxH < n {
			hpos = make([]int, 0, 300000)
			hpos = append(hpos, i)
			maxH = n
		} else if maxH == n {
			hpos = append(hpos, i)
		}
	}
	for i, n := range w {
		if maxW < n {
			wpos = make([]int, 0, 300000)
			wpos = append(wpos, i)
			maxW = n
		} else if maxW == n {
			wpos = append(wpos, i)
		}
	}

	ans := maxH + maxW - 1
	for _, hh := range hpos {
		for _, ww := range wpos {
			if xy[pair{hh, ww}] == 0 {
				out(ans + 1)
				return
			}
		}
	}
	out(ans)
}


Measured memory_bytes: 71200
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int a, b, c; std::cin >> a >> b >> c;
	auto lower = std::max({ a, b, c }) * 3;
	auto sum = a + b + c;
	if ((lower - sum) % 2 == 0) {
		std::cout << (lower - sum) / 2 << std::endl;
	}
	else {
		std::cout << (lower + 3 - sum) / 2 << std::endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

ll sz[51];
ll p[51];

ll rec(int n, ll x){
    if(n == 0) return max(0LL, x);
    if(sz[n] == x) return p[n];
    ll res = 0;
    res += rec(n - 1, min(sz[n - 1], x - 1));
    if(sz[n - 1] + 1 < x) res += 1;
    if(sz[n - 1] + 2 < x) res += rec(n - 1, min(sz[n - 1], x - (sz[n - 1] + 2)));
    return res;
}

signed main(){
    int n;
    ll x;
    cin >> n >> x;
    sz[0] = 1;
    for(int i = 1; i <= 50; i++){
        sz[i] = sz[i - 1] * 2 + 3;
    }
    p[0] = 1;
    for(int i = 1; i <= 50; i++){
        p[i] = p[i - 1] * 2 + 1;
    }
    cout << rec(n, x) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  
  int cnt=0;
  for(int i=0;i<n;i++){
    int data;
    cin>>data;
    if(data>=k){
      cnt++;
    }
  }
  cout<<cnt<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int main()
{
	char a[10], b[10];
	scanf("%s%s", a, b);
	strcat(a, b);
	int p = atoi(a);
	if(sqrt(p) != (int)(sqrt(p)))
		puts("No");
	else
		puts("Yes");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>void outarr(int s,int e,vector<T> &V){
	for(int i=s;i<e;i++)cout<<V[i]<<(i<e-1?" ":"\n");
}
// outarr<int>(0,V.size(),V);
// outarr<ll>(0,V.size(),V);

// #define NMAX 1000000000
double L;

double solve(){
	double ans = 0.0;

	double a,b,c;
	a = b = c = L/3;
	ans = a*b*c;
	return ans;
}

int main(){
	cin>>L;
	printf("%.12f\n",solve());
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int num, upper, lower;
    bool uflag = false, lflag = false;
    string s, tmp;
    cin >> tmp;
    num = atoi(tmp.c_str());
    upper = num / 100;
    lower = num % 100;
    
    if (upper > 0 && upper <= 12) {
        uflag = true;
    }
    if (lower > 0 && lower <= 12) {
        lflag = true;
    }

    if (uflag && lflag) {
        s = "AMBIGUOUS";
    } else if (uflag) {
        s = "MMYY";
    } else if (lflag) {
        s = "YYMM";
    } else {
        s = "NA";
    }
    cout << s << endl;
    return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

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

    int C[101][101];
    memset(C, 0, sizeof C);
    int N; cin >>N;
    vector<int> x(N);
    vector<int> y(N);
    vector<int> h(N);
    int sp = -1;
    rep(i, N) {
        cin >> x[i] >> y[i] >> h[i];
        if (h[i] != 0) sp = i;
    }

    rep(cx, 101) {
        rep(cy, 101) {
            bool ok = true;
            int tmp_h = h[sp] + abs(x[sp]-cx) + abs(y[sp]-cy);
            rep(i, N) {
                if (h[i] != max(tmp_h - abs(x[i]-cx) - abs(y[i]-cy), 0)) {
                    ok = false;
                    break;
                }
            }
            if (ok) {
                cout << cx SP cy SP tmp_h << endl;
                return 0;
            }
        }
    }
    
    cout << "boo!" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using P = pair<int, int>;
 
const int MAX = 3e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
 
int cnt_w[MAX], cnt_e[MAX];
 
int main() {
  // 入力
  int n;
  string s;
  cin >> n >> s;
 
  for (int i = 1; i < n; i++) {
    cnt_w[i] = cnt_w[i-1];
    if (s[i-1] == 'W') cnt_w[i]++;
  }
 
  for (int i = n - 2; i >= 0; i--) {
    cnt_e[i] = cnt_e[i+1];
    if (s[i+1] == 'E') cnt_e[i]++;
  }
 
  int ans = MAX;
  for (int i = 0; i < n; i++) {
    ans = min(ans, cnt_w[i] + cnt_e[i]);
  }
 
  // 解答
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
const ll N=2e5+2,M=998244353;
ll tr[N*4],lazy[N*4],pw[N],v[10][N];
void push_down(ll node,ll s,ll e,ll l,ll r)
{
    if(lazy[node]>0)
    {
        ll x=lazy[node];
        tr[node]=v[x][e-s+1];
        if(s<e) lazy[l]=x,lazy[r]=x;
        lazy[node]=0;
    }
}
void up(ll node,ll s,ll e,ll i,ll j,ll d)
{
    ll l=node*2;
    ll r=l+1;
    ll m=(s+e)/2;
    push_down(node,s,e,l,r);
    if(s>j || e<i)
    {
        return;
    }
    else if(s>=i && e<=j)
    {
        lazy[node]=d;
        push_down(node,s,e,l,r);
        return;
    }
    up(l,s,m,i,j,d);
    up(r,m+1,e,i,j,d);
    tr[node]=(tr[l]*pw[e-m]+tr[r])%M;
}
int main()
{
    ft
    ll i,j,n,l,r,q,d;
    cin>>n>>q;
    pw[0]=1;
    for(i=1;i<=n;i++)
    {
        pw[i]=(pw[i-1]*10)%M;
    }
    for(i=1;i<10;i++)
    {
        for(j=1;j<=n;j++)
        {
            v[i][j]=(v[i][j-1]*10+i)%M;
        }
    }
    up(1,1,n,1,n,1);
    while(q--)
    {
        cin>>l>>r>>d;
        up(1,1,n,l,r,d);
        cout<<tr[1]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 27476
#define _GLIBCXX_DEBUG

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

void insertionSort(vector<int>& data, int N)
{
    for(int i = 1; i < N; i++){
        int d_i = data.at(i);
        int j = i - 1;
        while((j >= 0) && (data.at(j) > d_i)){
            swap(data.at(j+1), data.at(j));
            j--;
        }
        rep(k, N){
            if (k == N - 1)
                cout << data.at(k);
            else
                cout << data.at(k) << ' ';
        }
        cout << endl;
    }
}

int main(){
    int N;
    cin >> N;

    vector<int> data(N);

    rep(i, N)
    {
        cin >> data.at(i);
    }

    rep(k, N)
    {
        if(k == N - 1)
            cout << data.at(k);
            else cout << data.at(k) << ' ';
    }
    cout << endl;
    insertionSort(data, N);
    return 0;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
long long n,k,h;
int a[1010];
int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
    	cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=n;i>=n-k+1;i--)h+=a[i];
	cout<<h<<endl;
	return 0;
}

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

const int N = 444, mod = 1e9 + 7;

int a[N], b[N], dp[N][N], d[N][N], p[N];

int f(int pos, int c) {
	if(pos < 1) {
		return c == 0;
	} 
	if(~dp[pos][c]) {
		return dp[pos][c];
	}
	int r = 0;
	for(int i = 0; i <= c; i++) {
		r += f(pos - 1, c - i) * ((d[i][b[pos]] - d[i][a[pos] - 1] + mod) % mod) % mod;
		r %= mod;
	}
	return dp[pos][c] = r;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, c; cin >> n >> c;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++) {
		cin >> b[i];
	}

	for(int i = 1; i < N; i++) {
		p[i] = 1;
		d[0][i] = d[0][i - 1] + p[i];
	}

	for(int i = 1; i < N; i++) {
		for(int j = 1; j < N; j++) {
			p[j] = (p[j] * j) % mod;
			d[i][j] = d[i][j - 1] + p[j] % mod;
		}
	}

	memset(dp, -1, sizeof dp);
	cout << f(n, c) << endl;
}

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

#define endl "\n"
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first 
#define ss second 
#define pii pair<int,int>
#define vi vector<int>
#define vc vector<char>
#define vii vector<pii>
#define vvi vector<vi>
#define fori(i,n) for(int i=1;i<=n;++i)
#define forn(i,n) for(int i=0;i<n;++i)
#define sz(x) int(x.size())
#define error(x) cout<<#x<<" "<<x<<endl
#define IOS  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

const int N=100*1000;
const int mod=1e9+7;

int min3(int a,int b,int c){return min(a,min(b,c));}
int max3(int a,int b,int c){return max(a,max(b,c));}
int min4(int a,int b,int c,int d){return min(min(a,b),min(c,d));}
int max4(int a,int b,int c,int d){return max(max(a,b),max(c,d));}

//#define int int64_t
//int a[N+2];

int32_t  main(){
	IOS;
  int a,p;cin>>a>>p;
  int ans=0;
  ans=(a*3)+p;
  ans/=2;
  cout<<ans<<endl;

  return 0;
}



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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll a, b;
  cin >> a >> b;

  if ((a * b) % 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}



int main(){
    vector<ll> A(3);
    cin>>A;
    sort(A.begin(),A.end());
    cout<<A[0]+A[1]<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
string a,b;
int q,l,r,l2,r2;
const int N=1e5+5;
vi pref(N,0),pref2(N,0);
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>a>>b>>q;
	//cin>>>a>>b>>q;
	rep(i,0,sz(a)) {
		if(a[i]=='B') pref[i+1]++;
		else pref[i+1]+=2;
		pref[i+1]+=pref[i];
	}
	rep(i,0,sz(b)) {
		if(b[i]=='B') pref2[i+1]++;
		else pref2[i+1]+=2;
		pref2[i+1]+=pref2[i];
	}
	rep(i,0,q) {
		cin>>l>>r>>l2>>r2;
		//cout<<(pref[l]-pref[r-1])<<' '<<(pref2[l2]-pref2[r2-1])<<endl;
		if((pref[r]-pref[l-1])%3==(pref2[r2]-pref2[l2-1])%3) {
			cout<<"YES"<<endl;
		} else cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 4176
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=100005;
ll dp[1005][1005];
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n, m;
	cin>>n>>m;
	char c;
	dp[0][1]=1;
	rep(i,1,n+1){
		rep(j,1,m+1){
			cin>>c;
			if(c=='#'){
				dp[i][j]=0;
			}
			else{
				dp[i][j]=(dp[i-1][j]+dp[i][j-1])%hell;
			}
		}
	}
	cout<<dp[n][m];
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 8064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int n, ans = 0;
    string s;
    cin >> n >> s;
    s.push_back('A');
    for(int i = 1; i <= n; i++){
        if(s[i - 1] != s[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
    ll t;
    cin>>t;
    ll k=0,a[t][2];
    for(ll i=0;i<t;++i)
    {
       cin>>a[i][0]>>a[i][1]; 
    }
    for(ll i=0;i<t;++i)
    {
        if(a[i][0]==a[i][1]&&i+1<t)
        {
            if(a[i+1][0]==a[i+1][1]&&i+2<t)
            {
                if(a[i+2][0]==a[i+2][1])
                {k+=1;i+=2;}

            }
        }
    }
    if(k)
    cout<<"Yes";
    else
    cout<<"No";
    
}

Measured memory_bytes: 3628
/*
对于每棵树，都满足每个点的子树点权和在mod 2意义下是1，所以可以从下往上递推出每个点权的奇偶性。需要满足每个点在两棵树中奇偶性相同，否则无解 
更具体地，当一个点有偶数个儿子时点权mod 2 = 1，有奇数个儿子时点权mod 2 = 0
有这么一种构造方法，只要令偶数点权 = 0，奇数点权 = +1或-1即可构造出解。具体如下（称点权mod 2 = 1的点为奇点）： 
选择任意一个奇点为特殊点。对于两棵树，首先从下往上进行匹配
匹配到点u时，每个子树中会多出一个奇点，包括u本身如果是奇点也算在内，会有2k + 1个奇点
这些点中如果有特殊点就去掉特殊点，否则去掉任意一个点。对于剩下的点，任意两两匹配。如果匹配了x和y就连一条无向边(x, y)。被去掉的点就是该子树多出来的点 
进行了这样的匹配操作后，显然有：
(1)任意u的子树中有2k + 1个奇点，其中有k对奇点两两匹配，被去掉的点就是在u处匹配时被去掉的点
(2)特殊点在两棵树中都没有参与匹配，度数 = 0
(3)非特殊点的奇点在两棵树中都恰好参与一次匹配，度数 = 2
图由若干个环构成，同时一个点连接的两条边是在不同的树中的匹配，所以每个环都是偶环，该图是二分图。令黑点权值 = +1，白点权值 = -1
进行这样的操作后，每一对匹配的点权和是0，每个子树的点权和由该子树中多出来的点决定。显然也就完成了构造 
*/

#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
const int Max_N(100050);

int N, Father[Max_N], Dist[Max_N];

int Get_Father(int x)
{
	if (Father[x] == x)
		return x;
	int root(Get_Father(Father[x]));
	Dist[x] ^= Dist[Father[x]];
	return Father[x] = root;
}

inline void merge(int u, int v)
{
	int x = Get_Father(u), y = Get_Father(v);
	if (x == y)
		return;
	Dist[y] = (Dist[v] ^ Dist[u] ^ 1), Father[y] = x;
}

struct T
{
	int root, Head[Max_N], Total, To[Max_N], Next[Max_N], Son[Max_N];
	inline void Add_Edge(int s, int t)
	{
		++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total;
	}
	void init()
	{
		for (int i = 1, fa;i <= N;++i)
		{
			scanf("%d", &fa);
			if (fa == -1)
				root = i;
			else
				Add_Edge(fa, i), ++Son[fa];
		}
	}
	int work(int u)
	{
		vector<int> All;
		for (int i = Head[u];i;i = Next[i])
			All.push_back(work(To[i]));
		if ((Son[u] & 1) == 0)
			All.push_back(u);
		sort(All.begin(), All.end());
		for (int i = 1;i < All.size();i += 2)
			merge(All[i], All[i + 1]);
		return All[0];
	}
};
T A, B;

int main()
{
	scanf("%d", &N), A.init(), B.init();
	for (int i = 1;i <= N;++i)
	{
		Father[i] = i, Dist[i] = 0;
		if ((A.Son[i] & 1) != (B.Son[i] & 1))
		{
			puts("IMPOSSIBLE");
			return 0;
		}
	}
	puts("POSSIBLE");
	A.work(A.root), B.work(B.root);
	for (int i = 1;i <= N;++i)
		if ((A.Son[i] & 1) == 0)
			printf("%d ", (Get_Father(i), Dist[i]) ? +1 : -1);
		else
			printf("%d ", 0);
	return 0;
}

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

int main() {
  ll h; cin >> h;
  ll ans = 1;
  while(h!=0) {
    h/=2;
    ans *= 2;
  }
  cout << ans - 1 << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <queue>
#include <cctype>
#include <climits>
#include <stack>
using namespace std;
 
int n,m,r;
const int INF=1e7;
int d[2][200][200];
int dp[1001][200];
 
int main(){
 
 
	while(scanf("%d %d",&n,&m),n){
		
	   for(int i=0;i<n;i++){
		  for(int j=0;j<n;j++) d[0][i][j]=d[1][i][j]=INF;
		  d[0][i][i]=d[1][i][i]=0;
	   }
		
	   for(int i=0;i<m;i++){
		  int x,y,t;
		  char c;
		  scanf("%d %d %d %c",&x,&y,&t,&c);
		  x--; y--;
		  
		  d[c=='L'][x][y]=min(d[c=='L'][x][y],t);
		  d[c=='L'][y][x]=min(d[c=='L'][y][x],t);
	   }
		
	   for(int k=0;k<n;k++){
		  for(int i=0;i<n;i++){
			 for(int j=0;j<n;j++){
				d[0][i][j]=min(d[0][i][j],d[0][i][k]+d[0][k][j]);
				d[1][i][j]=min(d[1][i][j],d[1][i][k]+d[1][k][j]);
			 }
		  }
	   }
	   
	   int now,z;
	   scanf("%d",&r);
	   scanf("%d",&now); now--;

	   fill(&dp[0][0],&dp[1001][0],INF);
	   dp[0][now]=0;
		
	   for(int i=0;i<r-1;i++){
		   scanf("%d",&z); z--;
		   
		   for(int j=0;j<n;j++){
			   dp[i+1][j]=min(dp[i+1][j],dp[i][j]+d[1][now][z]);
			   for(int k=0;k<n;k++){
				   // 
				   dp[i+1][k]=min(dp[i+1][k],dp[i][j]+d[1][now][j]+d[0][j][k]+d[1][k][z]);
			   }
			   
			   
		   }
		   now=z;
	   }


/*
	   //int res=INF;
	   for(int i=1;i<r;i++){
		  for(int j=0;j<n;j++){
							
			 for(int k=0;k<n;k++){
				dp[i][k]=min(dp[i][k],dp[i-1][j]+d[1][z[i-1]][j]+d[0][j][k]+d[1][k][z[i]]);
				//if(i==r-1 && res>dp[i][k]) res=dp[i][k];
			 }
			 dp[i][j]=min(dp[i][j],dp[i-1][j]+d[1][z[i-1]][z[i]]);
			 //if(i==r-1 && res>dp[i][j]) res=dp[i][j];
		  }
	   }
*/
	   printf("%d\n",*min_element(dp[r-1],dp[r]));
		
	}
}

Measured memory_bytes: 4244
#include <math.h>
#include <stdio.h>
int main(void){
    double r;
    scanf("%lf",&r);
    double menseki=pow(r,2.0)*M_PI;
    double ensyuu=2*r*M_PI;
    printf("%f %f",menseki,ensyuu);
    return 0;
}


Measured memory_bytes: 2080
"use strict";

function Main(input) {
    var ans="";
    for(var i=0;i<input.length;i++){
        var temp=input.charAt(i);
        if(temp === temp.toLowerCase())
            ans+=temp.toUpperCase();
        else
            ans+=temp.toLowerCase();
    }
    console.log(ans.trim());
}
    
function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 15732
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int main(){
  int n, k; cin >> n >> k;
  if(1+2*(k-1) <= n)  cout << "YES" << endl;
  else  cout << "NO" << endl;
  return 0;
}

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

const ll mod=1e9+7;
ll power(ll a,ll b){
	return b ? power(a*a%mod,b/2)*(b%2?a:1)%mod : 1;
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    ll dp[k+1],ans=0;
    for(ll i=k; i>=1; i--){
        dp[i]=power(k/i,n);
        for(ll j=2*i ; j<=k; j+=i) dp[i]-= dp[j];
        ans=(ans + i*dp[i] % mod) % mod;
    }
    cout<<(ans+mod)%mod;
    return 0;
}

Measured memory_bytes: 4436
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int v[5];
	for (int i = 0; i < 5; ++i)
		cin >> v[i];
	cout << *min_element(v, v + 3) + *min_element(v + 3, v + 5) - 50 << endl;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    bool ok = true;
    for(int i=0;i<n;i++){
        if(a[i] %2 == 0){
            if(a[i] %3 != 0 && a[i] %5 != 0){
                ok = false;
                break;
            }
        }
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

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

class Player{
private:
    bool played;
    queue<int> games;
    int id;
public:
    void Set_ID(int i);
    int Get_ID();
    void New_Day(vector<Player*>& active_players);
    bool Can_Play();
    int Next_Game();
    void Play();
    void Input(int i);
};

void Player::Set_ID(int i) {
  id = i;
}

int Player::Get_ID() {
  return id;
}

void Player::New_Day(vector<Player*>& active_players){
  if (played) active_players.push_back(this);
  played = false;
}

bool Player::Can_Play(){
  return !(played or games.empty());
}

int Player::Next_Game() {
  return games.front();
}

void Player::Play() {
  games.pop();
  played = true;
}

void Player::Input(int i) {
  games.push(i);
}

int main() {
  int n;
  cin >> n;
  vector<Player> players(n);
  vector<Player*> active_players(n);
  for (int i = 0; i < n; ++i) {
    players[i].Set_ID(i);
    active_players[i] = &players[i];
    for (int j = 0; j < n - 1; ++j) {
      int a;
      cin >> a;
      players[i].Input(a - 1);
    }
  }

  int game = 0;
  int day = 0;
  int prev_game = 0;

  while (game < n * (n - 1) / 2) {
    for (Player* player : active_players) {
      if (not player->Can_Play()) continue;
      Player* opponent = &players[player->Next_Game()];
      if (not opponent->Can_Play()) continue;
      if (player->Get_ID() == opponent->Next_Game()) {
        player->Play();
        opponent->Play();
        ++game;
      }
    }
    if (game == prev_game) {
      cout << -1 << endl;
      return 0;
    }
    prev_game = game;
    ++day;
    active_players.clear();
    for (Player& player: players) {
      player.New_Day(active_players);
    }
  }
  cout << day << endl;
  return 0;
}


Measured memory_bytes: 4736
import java.io.*;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int N, arr[] = new int[3];
		String str, tmp[];
		N = Integer.parseInt(in.readLine());
		for (int i = 0; i < N; i++) {
			str = in.readLine();
			tmp = str.split(" ", 0);
			for (int j = 0; j < 3; j++) {
				arr[j] = Integer.parseInt(tmp[j]);
				arr[j] *= arr[j];
			}
			Arrays.sort(arr);
			if (arr[2] == arr[0] + arr[1])
				System.out.println("YES");
			else
				System.out.println("NO");

		}

	}
}

Measured memory_bytes: 20308
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int prime(int x){
  for(int i=2;i*i<=x;i++){
    if( x%i==0 )return 0;
  }
  return 1;
}

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
        
  int n;
  cin >> n;
  for(int i=n;;i++){
    if(prime(i)){
      cout<<i << endl;
      return 0;
    }
  }
    

return 0;
}
///....


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

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int arr[] = new int[n];
		
		for(int i = 0; i<n; i++) {
			arr[i] = in.readInt()-1;
		}
		int count = 0; 
		int ans = 0; 
        while(true) {
        	if(ans == 1) {
        	  System.out.println(count);
        	  return;
        	}
            if(count > n) {
            	System.out.println(-1); 
            	return ; 
            }
            ans = arr[ans]; 
            count++;
        }
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin>>s;
  int counter=0;
  if (s[0] == 'o') counter++;
  if (s[1] == 'o') counter++;
  if (s[2] == 'o') counter++;
  cout<<700+100*counter<<endl;
}

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

int main() {
  vector<int> as(3);
  for(int i = 0; i < 3; ++i) {
    cin >> as[i];
  }
  sort(as.begin(), as.end());
  cout << (as[2] - as[0]) << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int N;

int main() {
    cin >> N;
    vector<pair<long long, long long>> A;
    for (int i = 0; i < N; i++) {
        long long a, b;
        cin >> a >> b;
        A.push_back(make_pair(a + b, a));
    }
    sort(A.begin(), A.end(), greater<pair<long long, long long>>());
    
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2) {
            ans -= A[i].first - A[i].second;
        } else {
            ans += A[i].second;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0,b=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]=='R')++r;
        else ++b;
    }
    if(r>b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

public class Main {

    private static final int[] DIGIT_TO_MATCHES = new int[]{0, 2 , 5 , 5 , 4 , 5 , 6 , 3 , 7 , 6 };

    public static void main(final String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] arr = new int[m];
        for (int i = 0; i < m; i++) {
            arr[i] = in.nextInt();
        }
        BigInteger[] dp = new BigInteger[n + 1];
        dp[0] = BigInteger.ZERO;
        for (int i = 0; i < n; i++) {
            if (dp[i] == null) {
                continue;
            }
            for (int j : arr) {
                int matches = DIGIT_TO_MATCHES[j];
                if (i + matches > n) {
                    continue;
                }
                BigInteger next = dp[i].multiply(BigInteger.TEN).add(BigInteger.valueOf(j));
                if (dp[i + matches] == null || dp[i + matches].compareTo(next) < 0) {
                    dp[i + matches] = next;
                }
            }
        }
        System.out.println(dp[n]);
    }
}


Measured memory_bytes: 101456
int main(void)
{
 int s = 0;
 int l = 0;
 int a = 0;
 int b = 0;
      
 scanf("%d %d",&a,&b);
 
 s = a*b;
 l = 2*(a+b);
       
 printf("%d %d\n",s,l);
 return 0;
}

Measured memory_bytes: 596
program sample
    implicit none
    real(8)::z
    integer(8) :: a,b,c,i,j,m,n,k,x,y
    character(100000)::s !文字列
    
  
    read(*,*)n,a,b

    read(*,*)s
   
    x=0
    y=0
   
    do i=1,n
        
        
        if (s(i:i)=='a')then
            if (x+y<a+b)then
                x=x+1
                write(*,*)'Yes'
            else
                write(*,*)'No'
            end if
        else if (s(i:i)=='b')then
           
            if (x+y<a+b)then
                if (y<b)then
                    y=y+1
                    write(*,*)'Yes'
                else
                    write(*,*)'No'
                end if
            else
                write(*,*)'No'
            end if
           

        else
            write(*,*)'No'
        end if

    end do
    
    stop
end program sample
  



Measured memory_bytes: 1316
export class Main {
  static main(input: string): string {
    const [n, ls] = input.split("\n");
    const nN = Number(n);
    const lList = ls.split(" ").map(Number);
    lList.sort((a, b) => b - a);
    const max = lList[0];
    let tmp = 0;
    for (let i = 1, len = lList.length; i < len; i++) {
      tmp += lList[i];
      if (max < tmp) {
        return "Yes"
      }
    }
    return `No`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define vll vector<pll>
#define vl vector<ll>
#define f first
#define s second
#define N 50000
#define pb push_back
#define mp make_pair
#define MAP map<ll,ll>
#define INF 1000000000
#define mod 1000000007
#define foo(i,a,b) for(ll i=(a);i<=(b);i++)
#define rep(i,a,b) for(ll i=(a);i>=(b);i--)
#define sl set<ll> 
#define sll set<pll>
#define ub upper_bound
#define lb lower_bound
using namespace std;
ll a[100000];
ll dp[100001][3];
int main(){
	fastio;
	ll n,a,b,c;
	vl A,B,C;
	cin>>n;
	foo(i,0,n-1){
		cin>>a>>b>>c;
		A.pb(a);
		B.pb(b);
		C.pb(c);
	}
	foo(i,1,n){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+A[i-1];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+B[i-1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+C[i-1];
	}
	cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
}

Measured memory_bytes: 5216
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dp[100010], p[15][15];
signed main(void)
{
	int n, d, x;
	cin >> n >> d >> x;
	REP(i, d) REP(j, n) cin >> p[i][j];
	
	REP(i, d-1) {
		REP(j, x+1) dp[j] = j;
		REP(j, n) REP(k, x+1) if(k>=p[i][j]) dp[k] = max(dp[k], dp[k-p[i][j]] + p[i+1][j]);
		
		x = max(x, dp[x]);
	}
	cout << x << endl;
}

Measured memory_bytes: 3204
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<climits>
#include<map>
#include<set>
#include<string>

#define pb push_back
#define all(a) (a).begin(),(a).end()

#define MAX_V 6000
#define INF (1<<29)

using namespace std;

struct edge{
  int to,cost;
  edge(int to,int cost):to(to),cost(cost){}
};

struct State{
  int d,c,id;
  State(int d,int c,int id):d(d),c(c),id(id){}
  bool operator < (const State &p)const{
    return d>p.d;
  }
};

vector<edge>G[MAX_V];
set<int>st;
int mincost[MAX_V][2001];

int dijkstra(int s,int g,int cap){

  priority_queue<State>que;
  que.push(State(0,cap*10,s));
  fill(mincost[0],mincost[MAX_V],INF);

  while(!que.empty()){
    State now=que.top();
    que.pop();

    if(now.id==g)return now.d;
    if(st.count(now.id))now.c=cap*10;
    if(mincost[now.id][now.c]<=now.d)continue;
    mincost[now.id][now.c]=now.d;

    for(int i=0;i<G[now.id].size();i++){
      int c=G[now.id][i].cost;
      int next=G[now.id][i].to;
      if(now.c<c)continue;
      int idx=(st.count(next)?cap*10:now.c-c);
      for(int j=0;j<=now.c-c;j++)
        mincost[next][j]=min(mincost[next][j],mincost[next][idx]);
      que.push(State(now.d+c,now.c-c,next));
    }
  }
  return -1;
}

vector<string>from,to;
vector<int>cost;
map<string,int>id;
set<string>v;

int main(void){

  int n,m,c;
  while(cin >> n >> m >> c,n|m|c){

    string s,dst,f,t;
    v.clear(),from.clear(),to.clear();
    cost.clear(),id.clear();
    int in;

    cin >> s >> dst;
    v.insert(s),v.insert(dst);

    for(int i=0;i<n;i++){
      cin >> f >> t >> in;
      from.pb(f),to.pb(t),cost.pb(in);
      v.insert(f),v.insert(t);
    }

    for(int i=0;i<MAX_V;i++)G[i].clear();

    set<string>::iterator it=v.begin();
    for(int j=0;it!=v.end();it++,j++)id[*it]=j;


    for(int i=0;i<n;i++){
      G[id[from[i]]].pb(edge(id[to[i]],cost[i]));
      G[id[to[i]]].pb(edge(id[from[i]],cost[i]));
    }

    string a;
    st.clear();
    for(int i=0;i<m;i++){
      cin >> a;
      if(id.count(a))st.insert(id[a]);
    }

    cout << dijkstra(id[s],id[dst],c) << endl;
  }

  return 0;
}

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

int main() {
  int N, M;
  cin >> N;
  vector<string> s(N);
  vector<int> point(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
    for (int j = 0; j < N; j++) {
      if (s.at(j) == s.at(i)) {
        point.at(j)++;
        break;
      }
    }
  }
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
    for (int j = 0; j < N; j++) {
      if (s.at(j) == t.at(i)) {
        point.at(j)--;
        break;
      }
    }
  }
  int money = 0;
  for (int i = 0; i < N; i++) {
    if (point.at(i) > money) {
      money = point.at(i);
    }
  }
  cout << money << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	int s1,s2,s3;
	s1=a+b;
	s2=a+c;
	s3=b+c;
	if(s1==c||s2==b||s3==a)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  /*
  文字列を削除するとサイズが変化する
  変化するのでwhile文で比較するのがよいかもしれない
  比較は，削除した動作の1つ前から見ていかないといけないかもしれない

  11011010001011
  のケースでミス-＞正確には12
  */
  int itr = 0;//イテレータ
  while(itr < s.size() - 1 && itr >= 0){
    if(s[itr] != s[itr+1]){
      //cout << "erase" << endl;
      s.erase(itr,2);
      itr--;
      if(itr < 0 && s.size() > 1)
        itr = 0;
      //itr = max(itr-2, 0);
    }
    else{
      itr++;
    }
    //cout << "s:" << s << endl;
  }
  //cout << "n:" << n << endl << "s:" << s << endl << "itr:" << itr << endl;
  cout << n - s.size() << endl;
}



Measured memory_bytes: 512
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

const int D_INFINITY=999999;


bool min_u(int&m, int v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


int calc(vi&nc, vi&d, vi&c, vvi&v, int x)
{
	nc.clear();
	for(int mc:c)
	{
		for(int mv:v[mc])
		{
			if(min_u(d[mv], x))
			{
				nc.push_back(mv);
			}
		}
	}
	return nc.size();
}


int main(void)
{
	int n, m;

	while(scanf("%d%d", &n, &m)==2)
	{
		vvi v(n+1);
		vi d(n+1, D_INFINITY);
		vi d1(n+1, D_INFINITY);
		vi d2(n+1, D_INFINITY);
		vi c;
		int s, t;

		for(int i=0;i<m;i++)
		{
			int a, b;
			scanf("%d%d", &a, &b);
			v[a].push_back(b);
		}
		scanf("%d%d", &s, &t);

		d[s]=0;
		c.push_back(s);
		for(int i=0;c.size();i++)
		{
			vi c1, c2;
			calc(c1, d1, c , v, i);
			calc(c2, d2, c1, v, i);
			calc(c , d , c2, v, i+1);
		}
		int ans=d[t];
		if(ans==D_INFINITY) ans=-1;

		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 6912
<?php
$hash=array();
$hash["q"]=0;
$hash["w"]=0;
$hash["e"]=0;
$hash["r"]=0;
$hash["t"]=0;
$hash["a"]=0;
$hash["s"]=0;
$hash["d"]=0;
$hash["f"]=0;
$hash["g"]=0;
$hash["z"]=0;
$hash["x"]=0;
$hash["c"]=0;
$hash["v"]=0;
$hash["b"]=0;
$hash["y"]=1;
$hash["u"]=1;
$hash["i"]=1;
$hash["o"]=1;
$hash["p"]=1;
$hash["h"]=1;
$hash["j"]=1;
$hash["k"]=1;
$hash["l"]=1;
$hash["n"]=1;
$hash["m"]=1;

while(fscanf(STDIN,"%s\n",$l)){
    if($l=="#")
        break;
    $flag=$hash[$l[0]];
    $sum=0;
    for($i=1;$i<strlen($l);$i++){
        if($flag!=$hash[$l[$i]]){
            $flag=$hash[$l[$i]];
            $sum++;
        }
    }
    echo $sum."\n";
}


?>

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// どういうDPか
// dp[i] := 山がi個のときに先手が勝つか

//
// dp[0] = false
// dp[i] = !dp[i-a[1]] or !dp[i-a[2]] or ...

bool dp[101010];

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    dp[0] = false;
    for (int i=0; i<=K; ++i) {
        for (int j=0; j<N; ++j) {
            if (i - A[j] >= 0) {
                dp[i] |= !dp[i-A[j]];
            }
        }
    }

    if (dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 384
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>

using namespace std;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a*b > c*d)cout << a*b;
	else cout << c*d;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define rep2(i,a,b) for(lint i=a;i<(lint)(b);i++)
#define PICK(N,m,p) (N/(int)(pow(p,m-1))-(N/(int)(pow(p,m)))*p)
using lint = long long;
using ld = long double;
using namespace std;

//ユークリッド互除法
lint gcd(lint x,lint y){
    lint a=MAX(x,y);
    lint b=MIN(x,y);
    if(b==0) return a;
    else {
        lint q=a/b;
        lint g=gcd(b,a-q*b);
        return g;
    }
}

//拡張ユークリッド互除法
lint ext_gcd(lint a, lint b, lint &x, lint &y){
    // a,b: GCDの対象 x=a, y=b
	if(b==0) {
		x=1;
		y=0;
		return a;
	}
	lint q=a/b;
	lint g=ext_gcd(b,a-q*b,x,y);
	lint z=x-q*y;
	x=y;
	y=z;
	return g;
}

int main(){
	lint L, R, d;
	cin >> L >> R >> d;
	int c=0;
	rep2(i,L,R+1) if(i%d==0) c++;
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 3600
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (A,B,C,D) = rd.readListLong()


    val ans = max(max(A*C, A*D), max(B*C, B*D))
    println(ans)
}


//val rd = debug.Reader("abc", "178", "b", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
const val EPS = 1e-9; fun DBLEQ(a: Double, b: Double): Boolean {return abs(a - b) < EPS}
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
data class To(val idx: Int, val cost: Long)
typealias ALI = ArrayList<Int>
fun <T>edge(V: Int): Array<ArrayList<T>> { return Array(V){ArrayList<T>()} }
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readDouble: () -> Double = { br.readLine().toDouble() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readIntArray: () -> IntArray = { readListInt().toIntArray() }
    val readLongArray: () -> LongArray = { readListLong().toLongArray() }
    val readListStringCol: (Int) -> List<String> = { N -> (0 until N).map { readString() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListIntCols: (Int) -> List<List<Int>> = { N -> (0 until N).map { readListInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val readListLongCols: (Int) -> List<List<Long>> = { N -> (0 until N).map { readListLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 36880
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main() {
   string s; cin >> s;
   print(s[0] + to_string(s.size() - 2) + s[s.size() - 1]);
}

Measured memory_bytes: 256