akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << (w*h)/2 << " ";
  if(x == (w/2) && y == (h/2)){
    cout << 1;
  } else { 
    cout << 0;
  }
  
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	ll n; cin>>n;
	string s; cin>>s;
	ll a=0,b=0,c=0;
	rep(i,0,n){
		if(s[i]=='R')++a;
		else if(s[i]=='G')++b;
		else ++c;
	}
	ll ans=a*b*c;
	rep(i,0,n){
		ll cnt=1;
		while(true){
			ll j=i+cnt;
			ll k=j+cnt;
			if(k>=n)break;
			if(s[i]!=s[j] && s[j]!=s[k] && s[i]!=s[k])--ans;
			++cnt;
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
    string s1,s2;
    cin >> s1;
    cin >> s2;
    int i=0,j=0,minnum;
    int L[1001][1001];
    for(i=0;i<1001;i++)
        L[0][i]=i;
    for(j=0;j<1001;j++)
        L[j][0]=j;
    for(i=1;i<=s1.size();i++)
        for(j=1;j<=s2.size();j++)
        {
            if(s1[i-1]==s2[j-1])
                L[i][j]=L[i-1][j-1];
            else   { 
                        minnum = min(L[i][j-1],L[i-1][j])+1;
                        L[i][j] = min(minnum,L[i-1][j-1]+1);
                   }
        }
    cout << L[s1.size()][s2.size()] << endl;
    return 0;
}


Measured memory_bytes: 7128
///           _____                  _______                  _____                   _____
///          /\    \                /::\    \                /\    \                 /\    \
///         /::\    \              /::::\    \              /::\____\               /::\    \
///        /::::\    \            /::::::\    \            /:::/    /              /::::\    \
///       /::::::\    \          /::::::::\    \          /:::/    /              /::::::\    \
///      /:::/\:::\    \        /:::/~~\:::\    \        /:::/    /              /:::/\:::\    \
///     /:::/__\:::\    \      /:::/    \:::\    \      /:::/    /              /:::/__\:::\    \
///    /::::\   \:::\    \    /:::/    / \:::\    \    /:::/    /              /::::\   \:::\    \
///   /::::::\   \:::\    \  /:::/____/   \:::\____\  /:::/    /      _____   /::::::\   \:::\    \
///  /:::/\:::\   \:::\    \|:::|    |     |:::|    |/:::/____/      /\    \ /:::/\:::\   \:::\    \
/// /:::/  \:::\   \:::\____|:::|____|     |:::|____|:::|    /      /::\____/:::/  \:::\   \:::\____\
/// \::/    \:::\  /:::/    /\:::\   _\___/:::/    /|:::|____\     /:::/    \::/    \:::\  /:::/    /
///  \/____/ \:::\/:::/    /  \:::\ |::| /:::/    /  \:::\    \   /:::/    / \/____/ \:::\/:::/    /
///           \::::::/    /    \:::\|::|/:::/    /    \:::\    \ /:::/    /           \::::::/    /
///            \::::/    /      \::::::::::/    /      \:::\    /:::/    /             \::::/    /
///            /:::/    /        \::::::::/    /        \:::\__/:::/    /              /:::/    /
///           /:::/    /          \::::::/    /          \::::::::/    /              /:::/    /
///          /:::/    /            \::::/____/            \::::::/    /              /:::/    /
///         /:::/    /              |::|    |              \::::/    /              /:::/    /
///         \::/    /               |::|____|               \::/____/               \::/    /
///          \/____/                 ~~                      ~~                      \/____/
//I am aqua
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define speed  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fo for(int i=0;i<n;i++) cin>>a[i];
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define l first
#define r second
#define input.txt ifstream fin("input.txt"); ofstream fout("output.txt");
using namespace std;
///--------------------------------------------------------------------------------------------------------------------

///--------------------------------------------------------------------------------------------------------------------

///--------------------------------------------------------------------------------------------------------------------
int main()
{
    int point=1,n;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(x==point)
            point++;
    }
    if(point==1)
    {
        cout<<-1;
        return 0;
    }
    cout<<n-point+1;
}
///I know that ;
///I know where I am
///Do not think I don't


Measured memory_bytes: 256
import numpy as np
N = int(input())
a_array = list(map(int,input().split()))

cnt = 0
now = 1
for i in range(N):
    if a_array[i] > now or a_array[i] < now:
        cnt += 1
    else:
        now += 1
if cnt == N:
    cnt = -1
print(cnt)

Measured memory_bytes: 34116
S = input()
N = len(S)
for i in range(N):
  if S[i] == 'U' or S[i] == 'D':
    continue
  else:
    if i % 2 == 0 and S[i] == 'R':
      continue
    elif i % 2 == 1 and S[i] == 'L':
      continue
  print("No")
  exit()
print("Yes")

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

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

typedef long long ll;

ll solve(ll a, ll b){
  if(a < b) return solve(b, a);
  if(a % b == 0LL) {
    return 2 * a - b;
  }else{
    return 2LL * b * (a / b) + solve(b, a % b);
  }
}

int main(){
  ll N, X;
  cin >> N >> X;
  ll res = N + solve(N - X, X);
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;
 
int main(){
    string s[] = {"BD","ACE","BF","AEG","BDFH"
		  ,"CEI","DH","EGI","FH"};
 
    for(int i = 0 ; i < 1000 ; i++){
	string str;
	bool possible = true;
 
	cin >> str;
	int size = str.size();
	for(int j = 1 ; j < size ; j++){
	    int k;
	    for(k = 0 ; k < s[str[j-1]-'A'].size() ; k++){
		if(str[j] == s[str[j-1]-'A'][k]){
		    break;
		}
	    }
	    if(k == s[str[j-1]-'A'].size()){
		possible = false;
		break;
	    }   
	}
	if(possible){
	    cout << str << endl;
	}
    }
    return 0;
}

Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double X[] = new double[N];
		String u[] = new String[N];

		double ans = 0;
		for (int i = 0; i < N; i++) {
			X[i] = sc.nextDouble();
			u[i] = sc.next();
			if (u[i].equals("BTC")) {
				ans += X[i] * 380000;
			} else {
				ans += X[i];
			}
		}
		sc.close();
		System.out.println(ans);
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
 
using namespace std;
 
 
// cin >>
// cout <<
int main(){
    int in=0;
	int out;
    while(scanf("%d",&in)!=EOF){
    out=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(i+j+k+l==in){
						out++;  
						}   
					}
				}
			}
		}
		printf("%d\n",out);
    }
    
     
    return 0;
}

Measured memory_bytes: 1188
X=int(input())
n=100004
L=[True]*n
L[0]=False
L[1]=False
for i in range(2,int(n**0.5)+1):
  if L[i]:
    for j in range(i*2,n):
      if j%i==0:
        L[j]=False
for i in range(X,n):
  if L[i]==True:
    print(i)
    exit()

Measured memory_bytes: 66492
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
vector<int> G[100100];
bool used[100100];
int V,E;
vector<int> topo;
int dp[100100];
void dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++)if(!used[G[v][i]])dfs(G[v][i]);
	topo.pb(v);
}
void construct_topo(){
	memset(used,false,sizeof(used));
	for(int i=0;i<V;i++)if(!used[i])dfs(i);
	reverse(all(topo));
}
int main(){
	scanf("%d %d",&V,&E);
	for(int i=0;i<E;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		a--;b--;
		G[a].pb(b);
	}
	construct_topo();
	/*for(int i=0;i<topo.size();i++)printf("%d ",topo[i]+1);
	printf("\n");*/
	for(int i=0;i<V;i++)dp[i]=0;
	int ans = 0;
	for(int i=0;i<V;i++){
		int v = topo[i];
		for(int j=0;j<G[v].size();j++){
			chmax(dp[G[v][j]],dp[v]+1);
		}
		chmax(ans,dp[v]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8056
n, k, c = gets.split.map(&:to_i)
s = gets.chop
l = Array.new(n, nil)
r = Array.new(n, nil)

cur = 0
prev = nil
0.upto(n-1) do |i|
  break if cur == k
  next if s[i] == 'x'
  next if prev && i - prev <= c

  l[i] = cur + 1
  cur += 1
  prev = i
end
cur = k+1
prev = nil
(n-1).downto(0) do |i|
  break if cur.zero?
  next if s[i] == 'x'
  next if prev && prev - i <= c

  r[i] = cur - 1
  cur -= 1
  prev = i
end
n.times do |t|
  if r[t] && l[t] && r[t] == l[t]
    puts t+1
  end
end

Measured memory_bytes: 6524
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

const int kMaxN = 100;

int N, D, X, A[kMaxN];
int ans = 0;

signed main() {
  cin >> N;
  cin >> D >> X;
  REP(i, N) { cin >> A[i]; }

  REP(i, N) { ans += 1 + (D-1)/A[i]; }
  ans += X;

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static int sumDigit( int num ) {
		
		int sum = 0;
		int n = num;
		
		while ( n > 0 ) {
			sum += n % 10;
			n = n / 10;
		}
		
		return sum;
	}

	public static void main(String[] args) {
		
		Scanner sc = new Scanner( System.in );
		
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		int sumnum = 0;
		
		for (int i = 1; i < N + 1; i++) {
			
			if ( A <= sumDigit(i) && sumDigit(i) <= B ) {
				sumnum += i;
			}
			
		}
		System.out.println(sumnum);

	}

}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<pair<int, int>> x(n);
  rep(i, n){
    int in;
    cin >> in;
    x.at(i) = make_pair(in, i);
  }
  sort(x.begin(), x.end());
  int lm = x.at(n/2-1).first, rm = x.at(n/2).first;
  vector<int> ans(n);
  rep(i, n){
    if(i < n/2) ans.at(x.at(i).second) = rm;
    else ans.at(x.at(i).second) = lm;
  }
  for(auto i : ans){
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
#define REP(i,b,e) for(int i=b; i<e; i++)

int main(){
	int h, w;
	scanf("%d %d", &h, &w);
	char fie[h][w+1], ans[h][w+1];
	REP(i, 0, h) scanf("%s", fie[i]);
	REP(i, 0, h){
		REP(j, 0, w){
			if(fie[i][j]=='#'){
				ans[i][j] = '#';
				continue;
			}
			int cnt = 0;
			REP(I, i-1, i+2) REP(J, j-1, j+2) {
				if(I==i and J==j) continue;
				if(I<0 or h<=I or J<0 or w<=J) continue;
				if(fie[I][J]=='#') cnt++;
			}
			ans[i][j] = cnt+'0';
		}
		ans[i][w] = '\0';
	}
	REP(i, 0, h) printf("%s\n", ans[i]);
	return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 998244353;
int n,maxn,a[1<<18];
ll f[1<<18],P[1<<18],ans[1<<18];
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
void fwt(ll *f,int tag){
	ll inv=fp(maxn,mod-2);
	for(int mid=1;mid<maxn;mid<<=1)
		for(int l=0;l<maxn;l+=mid<<1)
			for(int i=l;i<l+mid;i++){
				ll x=f[i],y=f[i+mid];
				f[i]=(x+y)%mod;
				f[i+mid]=(x-y)%mod;
			}
	if(tag<0)
	for(int i=0;i<maxn;i++)
		f[i]=f[i]*inv%mod;
}
int main(){
	read(n);maxn=1<<n;
	ll S=0;
	for(int i=0;i<maxn;i++)
		read(a[i]),S+=a[i];
	for(int i=0;i<maxn;i++)
		P[i]=a[i]*fp(S,mod-2)%mod;
	P[0]--;
	for(int i=0;i<maxn;i++)
		f[i]=-1;
	f[0]=maxn-1;
	fwt(f,1);fwt(P,1);
	for(int i=0;i<maxn;i++)
		ans[i]=f[i]*fp(P[i],mod-2)%mod;
	fwt(ans,-1);
	for(int i=0;i<maxn;i++)
		cout<<((ans[i]-ans[0])%mod+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 9984
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	fmt.Scan(&n)

	var tailA int
	var headB int
	var both int
	var ret int
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)

		ret += strings.Count(s, "AB")
		if s[0] == 'B' && s[len(s)-1] == 'A' {
			both++
		} else if s[0] == 'B' {
			headB++
		} else if s[len(s)-1] == 'A' {
			tailA++
		}
	}

	if both > 0 {
		ret += both - 1
		if tailA > 0 {
			ret++
			tailA--
		}
		if headB > 0 {
			ret++
			headB--
		}
	}

	if tailA > headB {
		ret += headB
	} else {
		ret += tailA
	}

	fmt.Println(ret)
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
    
    int n; cin >> n;

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

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

    b[0] = -b[0];
    
    for(int i = 1; i < n - 1; i++){
        if(b[i] < 0) b[i] = -b[i];
    }

    int sum = 0;
    for(int i = 0; i < n; i++) sum += b[i];

    
    vector<int> posi;
    vector<int> nega;

    for(int i = 0; i < n; i++){
        if(a[i] >= 0) posi.push_back(a[i]);
        else nega.push_back(a[i]);
    }

    cout << sum << endl;
    if(nega.size() == 0){
        int num = posi[0] - posi[1];
        cout << posi[0] << " " << posi[1] << endl;
        for(int i = 2; i < n - 1; i++){
            cout << num << " " << posi[i] << endl;
            num = num - posi[i];
        }
        cout << posi[n - 1] << " " << num << endl;

    }else if(posi.size() == 0){
        cout << nega[n - 1] << " " << nega[n - 2] << endl;
        int num = nega[n - 1] - nega[n - 2];
        for(int i = n - 3; i >= 0; i--){
            cout << num << " " << nega[i] << endl;
            num = num - nega[i];
        }
    }else{
        int nn = posi.size();
        for(int i = 0; i < nn - 1; i++){
            cout << nega[0] << " " << posi[i] << endl;
            nega[0] = nega[0] - posi[i];
        }

        for(int j = 0; j < nega.size(); j++){
            cout << posi[nn - 1] << " " << nega[j] << endl;
            posi[nn - 1] = posi[nn - 1] - nega[j];
        }
    }


    return 0;
}


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

#define rep(i,n) for (int i=0; i<(n); i++)
const ll INF =2*1e9+2;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    ll n, d;
    cin >> n >> d;
    ll ans = 0;
    rep(i, n){
        ll x, y;
        cin >> x >> y;
        if(d*d >= x * x + y * y) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n,c,k;
  cin >> n >> c >> k;

  vector<int> t(n);
  REP(i,n) cin >> t[i];
  
  sort(t.begin(), t.end());

  // int s = t[0];
  // int j = 0;
  // int cnt = 0;
  // REP(i,n){
  //   if(t[i] - s > k || ++j > c){
  //     s = t[i];
  //     cnt++;
  //     j = 0;
  //   }
  // }

  // cout << cnt + 1 << endl;

  int x = 0,y = 0;
  for(int i = 0; i < n;){
    x++;
    int tmp = t[i] + k;
    y = i + 1;
    while(y < n && y - i + 1 <= c && t[y] <= tmp) y++;
    i = y;
  }

  cout << x << endl;

  return 0;
}


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

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {

    vvi e(3, vi(3));
    rep(i, 3)rep(j, 3) cin>>e[i][j];

    int n;cin>>n;
    set<int> st;
    rep(i, n){
        int a;cin>>a;
        st.insert(a);
    }

    if (st.find(e[0][0])!=st.end() && st.find(e[0][1])!=st.end() && st.find(e[0][2])!=st.end()){
        cout << "Yes" << endl;
        return 0;
    }
    if (st.find(e[1][0])!=st.end() && st.find(e[1][1])!=st.end() && st.find(e[1][2])!=st.end()){
        cout << "Yes" << endl;
        return 0;
    }
    if (st.find(e[2][0])!=st.end() && st.find(e[2][1])!=st.end() && st.find(e[2][2])!=st.end()){
        cout << "Yes" << endl;
        return 0;
    }
    rep(i, 3){
        if (st.find(e[0][i])!=st.end() && st.find(e[1][i])!=st.end() && st.find(e[2][i])!=st.end()){
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (st.find(e[0][0])!=st.end() && st.find(e[1][1])!=st.end() && st.find(e[2][2])!=st.end()){
        cout << "Yes" << endl;
        return 0;
    }
    if (st.find(e[0][2])!=st.end() && st.find(e[1][1])!=st.end() && st.find(e[2][0])!=st.end()){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    num = int(input())
    counter = [0] * (num + 1)
    # func(41, 41, 41) = 10086
    # func(99, 1, 1) = 10002
    for x in range(1, 100):
        for y in range(1, 100):
            for z in range(1, 123 - x - y + 1):
                tmp = (x + y + z) ** 2 - x * y - y * z - z * x
                if tmp <= num:
                    counter[tmp] += 1
    for count in counter[1:]:
        print(count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9272
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N, M;
  cin >> N;
  multiset<string> s, t;
  for (int i = 0; i < N; i++)
  {
    string a;
    cin >> a;
    s.insert(a);
  }
  cin >> M;
  for (int i = 0; i < M; i++)
  {
    string a;
    cin >> a;
    t.insert(a);
  }
  int ans = 0;
  for (auto itr = s.begin(); itr != s.end(); itr++)
  {
    int snum = s.count(*itr);
    int tnum = t.count(*itr);
    ans = max(ans, snum - tnum);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N,M=map(int,input().split())
conflict=[tuple(map(int,input().split())) for i in range(M)]
conflict.sort(key=lambda x:x[0])
ans=0
Right=N
for i in range(M):
    if conflict[i][0]>=Right:
        Right=conflict[i][1]
        ans+=1
    else:
        Right=min(Right,conflict[i][1])
print(ans+1)

Measured memory_bytes: 18596
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;


template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};
int n;
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;
template< typename T >
vector< T > bellman_ford(Edges< T > &edges, int V, int s) {
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(V, INF);
  dist[s] = 0;
  for(int i = 0; i < V - 1; i++) {
    for(auto &e : edges) {
      if(dist[e.src] == INF) continue;
      dist[e.to] = min(dist[e.to], dist[e.src] + e.cost);
    }
  }
  for(auto &e : edges) {
    if(dist[e.src] == INF) continue;
    if(dist[e.src] + e.cost < dist[e.to]&&e.to==n) return vector< T >();
  }
  return dist;
}

main(){
    int k,x;cin>>k>>x;
    rep2(i,x-k+1,x+k-1)cout<<i<<" ";
}



Measured memory_bytes: 256
<?php
  $tmp = explode(" ",trim(fgets(STDIN)));

  $k = $tmp[0];
  $x = $tmp[1];

  $min = $x-$k+1;
  $max = $x+$k-1;

  if($min < -1000000){
    $min = -1000000;
  }
  if($max > 1000000){
    $max = 1000000;
  }
  
  $array = [];
  for($i=$min; $i<=$max; $i++){
    $array[] =  $i;
  }

  echo implode(" ",$array);


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    REP(i, n){
        cin >> s.at(i);
        reverse(ALL(s.at(i)));
    }

    vector<map<char, ll>> to(1);
    vector<ll> count(1, 0);

    for(const auto& si : s){
        ll cur = 0;
        for(char ci : si){
            if(to.at(cur).count(ci)){
                cur = to.at(cur).at(ci);
            }else{
                ll nxt = count.size();
                to.resize(nxt + 1);
                count.resize(nxt + 1);
                to.at(cur)[ci] = nxt;
                count.at(nxt) = 0;
                cur = nxt;
            }
        }
        count.at(cur)++;
    }

    assert(count.size() == to.size());

    // REP(i, to.size()){
    //     cerr << "count(" << i << ")=" << count.at(i) << endl;
    //     for(auto it = to.at(i).begin(); it != to.at(i).end(); ++it){
    //         cerr << "  " << it->first << " -> " << it->second << endl;
    //     }
    // }

    vector<array<ll, 26>> hist(count.size());

    for(const auto& si : s){
        vector<ll> pos;
        pos.push_back(0);
        for(char ci : si){
            ll cur = pos.back();
            pos.push_back(to.at(cur).at(ci));
        }
        assert(pos.size() == si.size() + 1);
        vector<bool> flg(26, false);
        RREP(i, si.size()){
            flg.at(si.at(i) - 'a') = true;
            REP(j, flg.size()){
                if(flg.at(j)){
                    hist.at(pos.at(i)).at(j) += 1;
                }
            }
        }
    }

    // REP(i, hist.size()){
    //     cerr << i << endl;
    //     REP(j, 26){
    //         if(hist.at(i).at(j) > 0){
    //             cerr << "  " << (char)('a' + j) << " = " << hist.at(i).at(j) << endl;
    //         }
    //     }
    // }

    ll ans = 0;
    for(const auto& si : s){
        ll cur = 0;
        REP(i, si.size() - 1){
            cur = to.at(cur).at(si.at(i));
        }
        // cerr << si << ' ' << cur << ' ' << hist.at(cur).at(si.back() - 'a') << endl;
        ans += hist.at(cur).at(si.back() - 'a') - 1;
    }
    cout << ans << endl;
    return 0;
}


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

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

	auto f = [](string t) {
		return ((t.size() % 2 == 0) && (t.substr(0, t.size() / 2) == t.substr(t.size() / 2, t.size())));
	};

	s.pop_back();

	while (!f(s))
	{
		s.pop_back();
	}

	cout << s.size() << endl;

	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<long long> a(N);
        for(int i=N-1;i>=0;i--) cin >> a[i];
        long long low = 2, high = 3;
        for(auto l : a){
            long long btm = (low + l - 1) / l;
            long long top = high / l;
            if(top == 0 || top < btm) { low = high = -1; break; }
            low = max(low, max(btm, 1LL) * l);
            high = max(low, top * l + l - 1);
        }
        if(a[0] != 2 || low < 0){
            cout << -1 << endl;
        } else {
            cout << low << " " << high << endl;
        }
    }   
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<array>
#include<deque>
#include<queue>
#include<map>
#include<cmath>
#include<stdio.h>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::array;
using std::queue;
using std::deque;
using std::priority_queue;
using std::multimap;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;
using std::sin;
using std::cos;
using std::log;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;
#define MOD 1000000007;
#define PI 3.141592653589793;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

int N, M;
bool sw[15][15];
int p[15], on[15];
int ans, lgt, maxi=1;

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

	cin >> N >> M;
	for(int i = 0; i < M; i++){
		int k;
		cin >> k;
		for(int j = 0; j < k; j++){
			int s;
			cin >> s;
			sw[i][s-1] = true;
		}
	}
	for(int i = 0; i < M; i++){
		cin >> p[i];
	}

	for(int i = 0; i < N; i++)maxi *=2;

	for(int i = 0; i < maxi; i++){
		for(int j = 0, jj = 1; j < N; j++){
			for(int k = 0; k < M; k++){
				if(sw[k][j] && ((i&jj)>0)){
					on[k]++;
				}
			}
			jj*=2;
		}

		for(int j = 0; j < M; j++){
			if(on[j]%2 == p[j]) lgt++;
			on[j] = 0;
		}
		if(lgt==M) ans++;
		lgt = 0;
	}

	cout << ans;


	return 0;
}


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

int main() {
    int r, g, b;
    int num;

    cin >> r >> g >> b;
    num = r*100+g*10+b;

    if (num % 4 == 0) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import deque


N, Q = map(int, input().split())
t = [[] for i in range(N + 1)]

for i in range(N - 1):
    a, b = map(int, input().split())
    t[a].append(b)
    t[b].append(a)

score = [0] * (N + 1)
for i in range(Q):
    p, x = map(int, input().split())
    score[p] += x

is_read = [False] * (N + 1)
d = deque()
d.append(1)

while len(d) != 0:
    now = d.popleft()
    is_read[now] = True
    for c in t[now]:
        if is_read[c]:
            continue
        score[c] += score[now]
        d.append(c)
print(" ".join(map(str, score[1:])))


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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;

ll x, y;

ll qmi(ll a, ll b, ll p)
{
    ll res = 1;
    while (b)
    {
        if (b & 1) res = res * a % p;
        a = a * (ll)a % p;
        b >>= 1;
    }
    return res;
}



ll C(ll a, ll b, ll p)
{
    if (b > a) return 0;

    ll res = 1;
    for (ll i = 1, j = a; i <= b; i ++, j -- )
    {
        res =   res * j % p;
        res =   res * qmi(i, p - 2, p) % p;
    }
    return res;
}


int main()
{
	scanf("%lld%lld", &x, &y);
	if((2 * y - x) % 3 || (2 * x - y) % 3 || (2 * y - x) < 0 || (2 * x - y) < 0)
	{
		puts("0");
		return 0;
	}
	ll n = (2 * y - x) / 3, m = (2 * x - y) / 3;
	
	cout << C(m + n, min(n, m), mod) << endl;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const int MAX_N = 100000;
int n;
int a[MAX_N];

int main()
{
  cin >> n;
  forn(i,n) cin >> a[i];

  int c = 0;
  multiset<int> s;
  forn(i,n) {
    if (s.empty() || *s.begin() >= a[i]) {
      c++;
    } else {
      auto it = s.lower_bound(a[i]);
      it--;
      s.erase(it);
    }
    s.insert(a[i]);
  }

  cout << c << endl;

  return 0;
}


Measured memory_bytes: 5376
n = int(input())
xs = list(map(int, input().split()))
 
ans = 0
sums = xs[0]
xors = xs[0]
i, j = 0, 0

while True:
  if xors == sums:
    ans += j - i + 1
    j += 1
    if j >= n: break
    sums += xs[j]
    xors ^= xs[j]
  else:
    sums -= xs[i]
    xors ^= xs[i]
    i += 1
    
print(ans)

Measured memory_bytes: 24840
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define sfi(a) scanf("%d",&a)
#define m_p make_pair
#define inf 1e9
#define ff first
#define ss second
#define pi(x) pair<x,x>
#define mem(x) memset(x,-1,sizeof(x))
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout)
#define FAST  ios_base::sync_with_stdio(0);cout.tie(0)

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
const int sz = 200001;
const ll M = 1e9+7;

ll store[sz+1];

ll nCr(ll n){
    if(n==0 || n==1) return 0;
    else if(n==2) return 1;
    else {
        ll ans = n * (n-1);
        ans /= 2;
        return ans;
    }
}

int main()
{
    int n;
    cin >> n;
    int arr[n+1];
    for(int i=1;i<=n;i++){
        cin >> arr[i];
        store[arr[i]]++;
    }

    ll ans = 0;
    for(int i=1;i<=n;i++){
        int val = store[i];
        ans += nCr(val);
    }

    for(int i=1;i<=n;i++){
        int val = store[arr[i]];
        ll tot = ans;
        tot -= nCr(val);
        tot += nCr((val-1));
        cout << tot << endl;
    }

    return 0;
}




Measured memory_bytes: 3968
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>

using namespace std;
#define MAX 100
typedef pair<int,int> pii;
typedef pair<double,pii> pp;

int main(void) {
    int R, N;
    while (cin>>R>>N && R) {
        vector<vector<int> > v(N, vector<int>(3));
        vector<int> h(R*2+1);
        for (int i = 0; i < N; i++) {
            cin >> v[i][0] >> v[i][1] >> v[i][2];
            if (v[i][0] > R || v[i][1] < -R) continue;
            int l = max(v[i][0]+R, 0);
            int r = min(v[i][1]+R , R*2+1);
            for (int j = l; j < r; j++) h[j] = max(h[j], v[i][2]);
        }
        
        double ans = 1e9;
        for (int i = 0; i < R; i++) {
            double x =sqrt(R*R - i*i);
            ans = min(ans, 1.0*h[R-1-i]-x);
            ans = min(ans, 1.0*h[R+i]-x);
        }
        printf("%.8lf\n",ans+R);
    }
}

Measured memory_bytes: 3236
#include <stdio.h>
#include <stdlib.h>

int main() {
    int *a = malloc(sizeof(int)), *b = malloc(sizeof(int));
    scanf("%d %d", a, b);
    int *z = malloc(sizeof(int));
    *z = 2*(*b) - *a;
    printf("%d\n", *z);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define double long double
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool integer(double n){
	if(n==long(n))return true;
	else return false;	
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
bool search(int x){
	int n;
	int a[n];
	int l=0,r=n;
	while(r-l>=1){
		int i=(l+r)/2;
		if(a[i]==x)return true;
		else if(a[i]<x)l=i+1;
		else r=i;
	}
	return false;
}
int ans[26];
signed main(){
	ic(n)
	rep(0,i,26)ans[i]=11;
	rep(0,i,n){
		sc(s)
		int t=s.size();
		int a[26];
		rep(0,j,26)a[j]=0;
		rep(0,j,t)a[s[j]-97]++;
		rep(0,j,26)ans[j]=min(ans[j],a[j]);
	}
	rep(0,i,26)rep(0,j,ans[i])cout<<char(i+97);
}	

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define mm(arr) memset(arr, 0, sizeof(arr))
#define scanArray(a,n) for(int i = 0; i < n; i++){cin >> a[i];}
#define pb push_back
#define PI 3.141592653589793
#define MOD 1000000007

using namespace std;
int main(){
    FAST
    int n; cin >> n;
    int a[n],b[n];
    int cnt=0;
    bool ok=0;
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        if(a[i] == b[i]){
            cnt++;
            if(cnt>=3){
                ok=1;
            }
        }
        else{
            cnt=0;
        }
    }
    if(ok==1){
        cout << "Yes" << endl;

    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
# Educational DP Contest A-Frog 1

def frog(N, h):
    # initialize
    inf = float('inf')
    dp = [inf] * (N)
    dp[0] = 0
    
    # DP
    for i in range(N):
        if i == 0:
            continue
        elif i == 1:
            dp[i] = abs(h[0] - h[1])
        else:
            dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
    return dp[N-1]
    
if __name__ == "__main__":
    N = int(input())
    h = list(map(int, input().split()))
    print(frog(N, h))

Measured memory_bytes: 52208
#include<stdio.h>
#include<string.h>
int main(){
  char s[201];
  int i,len,k;
  scanf("%s",s);
  len=strlen(s);
  if(len%2) s[len-1]=0;
  else {
    //s[len-1]=0;
    s[len-2]=0;
  }
  while(1){
    len=strlen(s);
    for(i=0;i<strlen(s)/2;i++){
      if(s[i]!=s[i+len/2]){
        k=0;
        break;
      }
      k=1;
    }
    if(k) break;
    else {
      //s[len-1]=0;
      s[len-2]=0;
    }
  }
  printf("%d",len);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int X;
  cin >> X;
  int A = X / 1000;
  int B = X % 1000 / 100;
  int C = X % 100 / 10;
  int D = X % 10;
  if (A+B+C+D == 7) {
    printf("%d+%d+%d+%d=7", A, B, C, D);
  } else if (A+B+C-D == 7) {
    printf("%d+%d+%d-%d=7", A, B, C, D);
  } else if (A+B-C+D == 7) {
    printf("%d+%d-%d+%d=7", A, B, C, D);
  } else if (A+B-C-D == 7) {
    printf("%d+%d-%d-%d=7", A, B, C, D);
  } else if (A-B+C+D == 7) {
    printf("%d-%d+%d+%d=7", A, B, C, D);
  } else if (A-B+C-D == 7) {
    printf("%d-%d+%d-%d=7", A, B, C, D);
  } else if (A-B-C+D == 7) {
    printf("%d-%d-%d+%d=7", A, B, C, D);
  } else if (A-B-C-D == 7) {
    printf("%d-%d-%d-%d=7", A, B, C, D);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <vector>
using namespace std;
int main() {
  const int card = 13;
  const string sort = "SHCD";
  int n, c;
  char s;
  vector<vector<int>> cards(4, vector<int>(card));
  cin >> n;

  for(int i=0; i<n; i++) {
    cin >> s >> c;
    if(s == sort[0]) {
      cards.at(0).at(c-1) = 1;
    } else if(s == sort[1]) {
      cards.at(1).at(c-1) = 1;
    } else if(s == sort[2]) {
      cards.at(2).at(c-1) = 1;
    } else if(s == sort[3]) {
      cards.at(3).at(c-1) = 1;
    }
  }
  for(int i=0; i<4; i++) {
    for(int j=0; j<card; j++) {
      if(cards.at(i).at(j) != 1) cout << sort[i] << " " << (j+1) << "\n";
    }
  }
  return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
 
 
 
int main() {
    double W, H, w, h, x, y;
    while (cin >> W >> H >> w >> h >> x >> y) {
    double left = max(-W/2, x - w/2);
    double right = min(W/2, x + w/2);
    double bottom = max(-H/2, y - h/2);
    double top = min(H/2, y + h/2);
 
    double cx = (left + right) / 2;
    double cy = (bottom + top) / 2;
    cout << fixed << setprecision(10) << cy / cx << endl;
    }
}


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

//べき乗
ll power(ll n,ll p){
    if(p == 0) return 1;
    if(p % 2 == 0){
        ll t = power(n,p/2);
        return t * t % MOD;
    }
    return n * power(n,p-1) % MOD;
}


//組み合わせ
ll combi(ll n,ll a){
    ll x = 1;
    ll y = 1;
    rep(i,a) {
        x = x * (n - i) % MOD;
        y = y * (a - i) % MOD;
    }
    return x * power(y,MOD-2) % MOD;
}

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = power(2,n) - combi(n,a) - combi(n,b) - 1;
    while(ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;

    string word[4] = {"dream", "dreamer", "erase", "eraser"};
    bool ok = false;
    queue<int> q; // うまく切れた場所の文字数をいれる
    q.push(0);
    while (!q.empty()) {
        int i = q.front();
        q.pop();
        if (i == S.size()) {
            ok = true;
            break;
        }

        for (auto w: word) {
            if (S.substr(i, w.size()) == w) q.push(i + w.size());
        }
    }

    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 512
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let list = input.split_whitespace().collect::<Vec<_>>();
    let a = list[0];
    let b = list[1];
    let x = format!("{}{}", a, b).parse::<i32>().unwrap();
    let y = {
        let n = (x as f64).sqrt().floor() as i32;
        n * n
    };
    if x == y { "Yes" } else { "No" }.to_string()
}

#[test]
fn test() {
    let tests = vec![("1 21", "Yes"), ("100 100", "No"), ("12 10", "No")];
    for (i, (input, output)) in tests.into_iter().enumerate() {
        println!("test:{}", i);
        assert_eq!(run(input.to_string()), output.to_string());
    }
}


Measured memory_bytes: 4352
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 
 
 
int main()
{
    int n;cin>>n;
    long long int ans = n + n*n + n*n*n;
    cout<<ans<<endl;
}


 


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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(lint i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


//---------------------------------------------------------------

void Main()
{
    lint A, B, ans;
    cin >> A >> B;
    ans = A - 2 * B;
    if(ans < 0) ans = 0;
    cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256