akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#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()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

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

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, k;
    string s;
    cin >> n >> s >> k;
    k--;

    char c = s[k];
    REP(i, n) if(s[i] != c) s[i] = '*';
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    
    int n;
    cin >> n;
    int cnt  = 0;
    bool flg = 0;

    for(int i=0;4*i<=n; i++){
        for(int j=0;7*j<=n;j++){
            if(n == 4*i + 7*j) {
                flg = 1;
            }
        }
    };

    if(flg)    cout << "Yes" << endl;
    else    cout << "No" << endl;

    return 0;
}




Measured memory_bytes: 256
n, m = map(int, input().split())

r = [0 for x in range(0, m)]

for _ in range(0, n):
    a = [x for x in map(int, input().split())]
    for i in a[1:]:
        r[i - 1] += 1

print('{}'.format(len([x for x in r if x == n])))


Measured memory_bytes: 3060
n = int(input())
H = list(map(int, input().split()))
dp = [-1] * n
dp[0] = 0
dp[1] = abs(H[1] - H[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(H[i] - H[i-1]), dp[i-2] + abs(H[i] - H[i-2]))
print(dp[n-1])

Measured memory_bytes: 20512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

const int buff_size = 1 << 21;
char buff[buff_size], *ci, ct;

inline int readint() {
    int A = 0;
    while ((ct = *ci++) >= '0') A = (A << 3) + (A << 1) + ct - '0';
    return A;
}

inline ll solve() {
    fread_unlocked(buff, 1, buff_size, stdin);
    ci = buff;
    int N = readint();
    int M = 2, cnt;
    ll ans = readint() - 1;
    REP(i, N-1) {
        int A = readint();
        if(A == M) M++;
        else {
            cnt = A / M;
            ans += cnt;
            if(A - cnt * M == 0) ans--;
        }
    }
    return ans;
}

int main() {
    printf("%lld\n", solve());
	return 0;
}

Measured memory_bytes: 1280
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int c = 8000;
    string s; cin >> s;
    int x,y; cin >> x >> y;
    int nowx = 0;
    REVERSE(s);
    while(s.size() && s.back() == 'F'){
        nowx++; s.pop_back();
    }
    bitset<16100> bx,by;
    bx[nowx+c] = 1; by[c] = 1;

    bool flag = true;
    while(s.size()){
        if(s.back() == 'T'){
            int nt = 0;
            while(s.size() && s.back() == 'T'){
                nt++; s.pop_back();
            }
            if(nt%2) flag = !flag;
        }
        else{
            int nf = 0;
            while(s.size() && s.back() == 'F'){
                nf++; s.pop_back();
            }
            if(flag) bx = (bx>>nf) | (bx<<nf);
            else by = (by>>nf) | (by<<nf);
        }
    }
    cout << (bx[x+c] && by[y+c] ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{

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

int a = sc.nextInt();
int b = sc.nextInt();

String shutsuryoku;

if(a < b){
System.out.println("a < b");
}else if(a > b){
System.out.println("a > b");
}else if(a == b){
System.out.println("a == b");
}


}
}



Measured memory_bytes: 26264
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n = int(input())
    c = input().rstrip('\n')
    r = c.count('R')
    s = 0
    for i in range(n):
        if c[i]=='R':
            w = c[s:i].count('W')
            ans += min(w,r)
            s = i
            r -= w+1
            if r <= 0:
                break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9496
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;

		if (A >= 13) {
			ans = B;
		} else if (6 <= A && A <= 12) {
			ans = B / 2;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import java.util.*;
import java.util.Arrays;
public class Main{
    
    public static boolean keta(int k){
        int ans =0;
        while(k>0){
            k /=10;
            ans++;

        }
        if(ans%2==0){
            return false;

        }
        else{
            return true;
        }
    }
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count =0;
        for(int i=1;i<=n;i++){
            if(keta(i)){
                count++;

            }
        }
        System.out.println(count);

        
        
    }
   
    
       
    
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long y){
       for(int i=2;i<=sqrt(y);i++)
              if(y%i==0)
                   return false;
         return true;
}
int main(){           
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   //freopen("input.in","r",stdin);
   long long x;
   cin>>x;
   while(!isPrime(x)){
     x++; 
   }
   cout<<x;
   return 0;              
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<complex>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#include <numeric>
using namespace std;
using Complex = complex<double>;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
const double EPS = 1e-10;
double PI = acos(-1.0);
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)


struct Segmenttree {
	static const int N = 1 << 18;
	vector<ll>seg;
	vector<ll>idx;
	void st(ll p, ll v) {
		p += N - 1;
		seg[p] = v;
		idx[p] = p - N + 1;
		while (p > 0) {
			p = (p - 1) / 2;
			seg[p] = max(seg[2 * p + 1], seg[2 * p + 2]);
			if (seg[2 * p + 1] < seg[2 * p + 2])idx[p] = idx[2 * p + 2];
			else if (seg[2 * p + 1] > seg[2 * p + 2])idx[p] = idx[2 * p + 1];
			else idx[p] = min(idx[2 * p + 1], idx[2 * p + 2]);
		}
	}
	pair<ll, ll> query(ll l, ll r, ll a, ll b, ll k) {
		if (r <= a || b <= l)return { -inf,inf };
		if (l <= a && b <= r)return { seg[k],idx[k] };
		ll m = (a + b) / 2;
		auto p1 = query(l, r, a, m, 2 * k + 1);
		auto p2 = query(l, r, m, b, 2 * k + 2);
		if (p1.first > p2.first) return p1;
		else if (p1.first < p2.first)return p2;
		else return { p1.first,min(p1.second,p2.second) };
	}

	void init() {
		seg.resize(2 * N);
		idx.resize(2 * N);
		for (int i = 0; i < 2 * N; i++)seg[i] = -inf;
	}
	//[l,r]
	ll get(int l, int r) {
		return query(l, r + 1, 0, N, 0).first;
	}
	ll getidx(int l, int r) {
		return query(l, r + 1, 0, N, 0).second;
	}
	pair<ll, ll>getp(int l, int r) {
		return query(l, r + 1, 0, N, 0);
	}
};


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

	Segmenttree seg1 = Segmenttree();
	Segmenttree seg2 = Segmenttree();

	ll n, q;
	cin >> n >> q;
	seg1.init(), seg2.init();

	for (int i = 0; i < n-2; i++)seg1.st(i,-1),seg2.st(i,-1);


	ll cur = (n - 2)*(n - 2);
	for (int i = 0; i < q; i++) {
		int t, x;
		cin >> t >> x;
		x -= 2;
		if (t == 1) {
			int ok = -1, ng = n - 2;
			while (ng - ok > 1) {
				int mid = (ng + ok) / 2;
				if (seg1.get(0,mid) < x)ok = mid;
				else ng = mid;
			}
			cur -= (ok + 1);
			seg2.st(x,ok);
		}
		else {
			int ok = -1, ng = n - 2;
			while (ng - ok > 1) {
				int mid = (ng + ok) / 2;
				if (seg2.get(0, mid) < x)ok = mid;
				else ng = mid;
			}
			cur -= (ok + 1);
			seg1.st(x, ok);
		}
	}
	puts(cur);

	return 0;
}

Measured memory_bytes: 19576
#include <bits/stdc++.h>
#define MOD 1000000007
#define MAX 10005
#define int long long
#define T int t;cin>>t;while(t--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define debug(x) cout<<x = <<x<<n;
#define set_dp(dp) memset(dp,-1,sizeof(dp))
using namespace std;

signed main(){
	ios_base::sync_with_stdio(false);	
	cin.tie(0);
	cout.tie(0);
	
 	string s;
 	cin>>s;
 	set<char> st;
 	for(auto c:s){
 		st.insert(c);
 	}
 	st.size()==2?cout<<"Yes":cout<<"No";

	return 0;
}



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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string a, s, c; cin >> a >> s >> c;
    cout << 'A' << s[0] << 'C' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;


int main() {
    while (true){
        int n, s;
        double m = 0, x = 0;
        cin >> n;
        vector<double> si(n);
        if (n == 0) break;
        for (int i = 0; i < n; i++){
            cin >> si[i];
        }
        for (int i = 0; i < n; i++){
            m += si[i];
        }
        for (int i = 0; i < n; i++){
            x += ((si[i]-m/n) * (si[i]-m))/n;
        } 
    cout << sqrt(x) << endl;
    }
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c) cout << 1 << endl;
  else if (a == b || b == c || c == a) cout << 2 << endl;
  else cout << 3 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;
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<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int H,W;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> H >> W;
  char d[H][W];
  for(int i = 0 ; i < H ; i++){
    for(int j = 0 ; j < W ; j++){
      cin >> d[i][j];
    }
  }


  for(int i = 0 ; i < H ; i++){
    bool can_del = true;
    for(int j = 0 ; j < W ; j++){
      if(d[i][j] == '#'){
        can_del = false;
        break;
      }
    }
    if(can_del){
      for(int j = 0 ; j < W ; j++){
        d[i][j] = '*';
      }
    }
  }

  for(int j = 0; j < W ; j++){
    bool can_del = true;
    for(int i = 0 ; i < H ; i++){
      if(d[i][j] == '#'){
        can_del = false;
        break;
      }
    }
    if(can_del){
      for(int i = 0 ; i < H ; i++){
        d[i][j] = '*';
      }
    }
  }

  for(int i = 0 ; i < H ; i++){
    bool line_empty = true;
    for(int j = 0 ; j < W ; j++){
      if(d[i][j] != '*'){
        cout << d[i][j];
        line_empty = false;
      }
    }
    if(!line_empty) cout << endl;
  }

  return 0;
}


Measured memory_bytes: 888
import sys
input = sys.stdin.readline


def main():
    A, B, H, M = map(int, input().split())
    import math
    rb = math.pi * 2 * 6*M / 360
    ra = math.pi * 2 * (30*H + 0.5*M) / 360
    ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(ra-rb))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9432
//For higher stack size use g++ -O2 -std=c++11 -Wall -Wl,--stack=268435456 a.cpp -o a.exe in cmd
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;

    ld ans,n;
    ll ar[101],ar2[101];

    ld dist(int i,int j)
    {
        return sqrt((ld)1.0*((ar[i]-ar[j])*(ar[i]-ar[j]) + (ar2[i]-ar2[j])*(ar2[i]-ar2[j])));
    }

    int flag[101];
    vector<int> v;
    vector<vector<int>>v2;
    map<vector<int>,int> mp;

    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int i,j;
            cin>>n;
            for(i=1;i<=n;++i)
            {
                cin>>ar[i]>>ar2[i];
            }
            ll fact2=1;
            for(i=1;i<=n-1;++i)
                fact2=fact2*i;
            for(i=1;i<=n;++i)
            {
                for(j=i+1;j<=n;++j)
                {
                    ans=ans+2*dist(i,j)*fact2;
                }
            }
            ll fact=1;
            for(i=1;i<=n;++i)
                fact=fact*i;
            ans=ans/fact;
            printf("%.9Lf\n",ans);
        }
        return 0;
    }


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		int A = GetInt();
		int B = GetInt();
		Console.WriteLine((A % 3 == 0) || (B % 3 == 0) || ((A + B) % 3 == 0) ?
			"Possible" : "Impossible");
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
using namespace std;

struct Node
{
    int key;
    Node *right,*left,*parent;
};
Node *root,*NIL;
////////////////////////////
Node *find(Node *u,int k)
{
    while(u!=NIL&&k!=u->key)
    {
        if(k<u->key)u=u->left;
        else u=u->right;
    }
    return u;
}
////////////////////////////
void insert(int k)
{
    Node *y=NIL;
    Node *x=root;
    Node *z;

    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;

    while(x!=NIL)
    {
        y=x;
        if(z->key<x->key)
        {
            x=x->left;
        }
        else
        {
            x=x->right;
        }
    }
    z->parent=y;
    if(y==NIL)
    {
        root=z;
    }
    else
    {
       if(z->key<y->key)
       {
            y->left=z;
       }
     else
     {
        y->right=z;
     }
    }
}
//////////////////////////////
Node * treeminimum(Node *x)
{
    while(x->left!=NIL)x=x->left;
    return x;
}
/////////////////////////
void inorder(Node *u)
{
    if(u==NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
/////////////////////////
void preorder(Node *u)
{
    if(u==NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
////////////////////////
Node * treesuccessor(Node *x)
{
    if(x->right!=NIL)return treeminimum(x->right);
    Node *y=x->parent;
    while(y!=NIL&&x==y->right)
    {
        x=y;
        y=y->parent;
    }
    return y;
}
////////////////////////
void treedelete(Node *z)
{
    Node *y;
    Node *x;
    if(z->left==NIL||z->right==NIL)y=z;
    else y=treesuccessor(z);
    if(y->left!=NIL)
    {
        x=y->left;
    }
    else{
        x=y->right;
    }
    if(x!=NIL)
    {
        x->parent=y->parent;
    }

    if(y->parent==NIL)
    {
        root=x;
    }
    else {

        if(y==y->parent->left)
        {
            y->parent->left=x;
        }
        else
        {
            y->parent->right=x;
        }
    }
    if(y!=z)
    {
        z->key=y->key;
    }
    free(y);
}
int main()
{
    int n,i,x;
    string com;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        cin>>com;
        if(com[0]=='f')
        {
            scanf("%d", &x);
            Node *t=find(root,x);
            if(t!=NIL)printf("yes\n");
            else printf("no\n");
        }

        else if(com=="insert")
        {
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        else if(com=="delete")
        {
            scanf("%d", &x);
            treedelete(find(root,x));
        }
    }
    return 0;
}

Measured memory_bytes: 22004
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int n = vs[0];
			int q = vs[1];

			long[] ans = new long[n];

			List<int>[] tree = new List<int>[n];
			bool[] flg = new bool[n];
			for (int i = 0; i < n; i++) {
				tree[i] = new List<int>();
			}
			for (int i = 0; i < n - 1; i++) {
				vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
				int a = vs[0] - 1;
				int b = vs[1] - 1;
				tree[a].Add(b);
				tree[b].Add(a);
			}

			for (int i = 0; i < q; i++) {
				vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
				int p = vs[0] - 1;
				int x = vs[1];
				ans[p] += x;
			}

			Queue<int> queue = new Queue<int>();
			queue.Enqueue(0);
			while (queue.Count > 0) {
				int root = queue.Dequeue();
				foreach (var leaf in tree[root]) {
					if (!flg[leaf]) {
						System.Diagnostics.Debug.WriteLine($"ans[{leaf}]{ans[root] + ans[leaf]} = ans[{root}]{ans[root]} + ans[{leaf}]{ans[leaf]}");
						ans[leaf] += ans[root];
						queue.Enqueue(leaf);
					}
				}
				flg[root] = true;
			}
			Console.WriteLine(string.Join(" ", ans));


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 55404
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int hi;
    cin >> hi;
    if (hi >= k) 
      ans++;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        char[] ch = new char[n];
        for(int i=0; i<n; i++) {
            ch[i] = s.charAt(i);
        }
        int count = 1;
        for(int i=0; i<n-1; i++) {
            if(ch[i] != ch[i+1]) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 39440
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<62)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    string s,t;
    cin >> s >> t;

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

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3824
n, w = map(int, input().split())
weights, values = zip(*[tuple(map(int, input().split())) for _ in range(n)])
UV = 10**5
INF = float('inf')
dp = [[0]+[INF]*UV for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, UV+1):
        dp[i][j] = dp[i-1][j]
        if 0 <= j-values[i-1]:
            dp[i][j] = min(dp[i][j], dp[i-1][j-values[i-1]]+weights[i-1])

ans = 0
for i in range(UV+1):
    if dp[-1][i] <= w:
        ans = max(ans, i)
print(ans)


Measured memory_bytes: 385176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
const int MAXN = 2e5 + 5, MAXM = 3e5 + 5, BOUND = 1e7, MOD = 1073741824, INF = 0x3f3f3f3f, base = 10000;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0), eps = 1e-9;
#define mid l + ((r-l)>>1)
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define lc(x) ch[x][0]
#define pii pair<int,int>
#define vi vector<int>
#define RR register int
#define rc(x) ch[x][1]
#define rep(i,a,b) for(RR i=(a);i<=(b);++i)
#define random(a,b) ((a)+rand()%((b)-(a)+1))

int n;
int c[MAXN], v[MAXN];
int main() {
	cin >> n;
	rep(i, 0, n - 1)cin >> v[i];
	rep(i, 0, n - 1)cin >> c[i];
	int ans = 0;
	for (int i = 0; i < 1 << n; i++) {
		int sum1 = 0, sum2 = 0;
		rep(j, 0, n - 1) {
			if ((1 << j)&i) {
				sum1 += v[j];
				sum2 += c[j];
			}
		}
		ans = max(ans, sum1 - sum2);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

// ����̕�����𐔂���֐�
size_t count(const string& str, const string& sub, const size_t ini = 0, const size_t fin = string::npos) {
	size_t pos = str.find(sub, ini);
	size_t cnt = 0;
	while (pos < fin) {
		cnt += 1;
		pos = str.find(sub, pos + sub.length());
	}
	return cnt;
}

int main() {

	int N;
	cin >> N;

	string c;
	cin >> c;
	
	int iW = 0;
	int iR = c.size() - 1;

	int ans = 0;
	int iWd = 0;
	int iRd = 0;
	while (iW < iR) {
		for (int i = iW; i < c.size(); i++) {
			iWd = i;
			if (c[i] == 'W') {
				break;
			}
		}
		for (int i = iR; i >= 0; i--) {
			iRd = i;
			if (c[i] == 'R') {
				break;
			}
		}
		if (iWd < iRd) {
			iW = iWd + 1;
			iR = iRd - 1;
			ans += 1;
		}
		else {
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	ll N, A, B;
	cin >> N >> A >> B;
	ll AB = A + B;
	ll ABcount = N / AB;
	ll ABrem = N - AB * ABcount;
	ll ans = ABcount * A;
	ans += min(A, ABrem);


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

Measured memory_bytes: 256
def main():
    N, D = map(int, input().split())
    XY = [list(map(int, input().split())) for _ in range(N)]

    ans = 0

    for xy in XY:
        if xy[0]**2 + xy[1]**2 <= D ** 2:
            ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 45448
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

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

int main()
{
    int n,k;
    cin >> n >> k;
    vector<pair<ll,ll> > sushi(n);
    for(int i = 0; i < n; i++){
    	cin >> sushi[i].second >> sushi[i].first;
    }

    priority_queue< pair<ll,ll> > que;
    for(int i = 0; i < n; i++){
    	que.push(sushi[i]);
    }

    ll num_sushi = 0;
    vector<ll> score(n+1,0);
    vector<int> flag(n+1,0);
    ll res = 0;
    priority_queue< pair<ll,ll> > que_res;

    for(int i = 0; i < k; i++){
    	pair<ll,ll> q = que.top();
    	que.pop();
    	res += q.first;
    	if(flag[q.second]==0){
    		flag[q.second] = 1;
    		num_sushi++;
    	}else{
    		q.first *= -1;
    		que_res.push(q);
    	}
    }

    score[num_sushi] = res + num_sushi*num_sushi;
   	while(!que.empty()){
    	if(num_sushi == k) break;

    	pair<ll,ll> q = que.top();
    	que.pop();
    	if(flag[q.second]==0){
    		res = score[num_sushi] - num_sushi*num_sushi;
    		pair<ll,ll> q2 = que_res.top();
    		que_res.pop();
    		flag[q.second]++;
    		num_sushi++;
    		res += q2.first;
    		res += q.first;
    		score[num_sushi] = res + num_sushi*num_sushi;
    	}
    }

    cout << *max_element(all(score)) << endl;


    return 0;
}

Measured memory_bytes: 6128
#include <iostream>
using namespace std;
int main() {
    int *p, *a;
    int n;
    cin>>n;
    p = new int[n];
    a = new int[n];
    for (int i=0;i<n;i++) cin>>a[i];
    p[0]=0;
    p[1]= abs(a[0]-a[1]);
    for (int i=2;i<n;i++)
        p[i] = min(p[i-1]+abs(a[i-1]-a[i]), p[i-2]+abs(a[i]-a[i-2]));
    cout<<p[n-1];
}


Measured memory_bytes: 4344
/*
by:-  
                     _ __ ___ 119574 
                    | '__/ __| 
                    | |  \__ \ 
                    |_|  |___/ 
                    

*/ 

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double db;
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,n) for (ll i = 0; i < n; ++i) 
#define endl "\n"
const ll mod=1e9+7;
const db eps=1e-9;
const double pi=acos(-1);

void solve(){
    ll a,b;
    cin>>a>>b;
    if(a<=5)cout<<0;
    else if(a<=12)cout<<b/2;
    else cout<<b;
    cout<<endl;


	return;
}
signed main(){
	IOS;
	ll t=1;
// 	cin>>t;
	while(t--)solve();
fflush(stdout);return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    string S,T;
    ll N,ans=0,A,B;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>A>>B;
    EREP(i,N){
        int res=i,sum=0;
        while(res/10){
            sum+=res%10;
            res/=10;
        }
        sum+=res;

        if(A<=sum&&sum<=B)ans+=i;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int h1,m1,s1,h2,m2,s2;
  while(cin >>h1>>m1>>s1>>h2 >>m2>>s2){
    h1 = h1*3600; h2 = h2*3600;
    m1 = m1*60; m2 = m2*60;
    s1 = h1+s1+m1; s2=h2+m2+s2;
    s2-=s1;
      cout << s2/3600 << " ";
      s2 %= 3600;
      cout << s2/60 << " ";
      s2 %= 60;
      cout << s2 << endl;
   }
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll A,B;
ll i, j, k,ans;

int main(){
    scanf("%lld%lld",&A,&B);
    if(1<=A&&A<=9&&1<=B&&B<=9){
        printf("%lld", A * B);
    }else{
        printf("-1");
    }

    return 0;
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0); 
  string s;
  cin >> s;
  int sum = 0;
  for (auto c : s) 
    sum += c - '0';
  cout << (sum % 9 == 0 ? "Yes" : "No");
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,a[N],g[N],f[N];
vector<int>e[N];
void dfs(int x)
{
	int cnt=0;
	for (int i=0;i<e[x].size();i++)
		dfs(e[x][i]);
	for (int i=0;i<e[x].size();i++)
		g[++cnt]=f[e[x][i]];
	sort(g+1,g+cnt+1);
	for (int i=1;i<=cnt;i++)
		f[x]=max(f[x],g[i]-i+cnt+1);
}
int main()
{
	scanf("%d",&n);
	for (int i=2;i<=n;i++)
	{
		scanf("%d",&a[i]);
		e[a[i]].push_back(i);
	}
	dfs(1);
	printf("%d\n",f[1]);
	
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main()
{
    ll a,b,i,j,n,m,k,t;
    cin>>n>>k;
    ll count=0;
    while(n--)
    {
        cin>>a;
        if(a>=k) count++;
    }
    cout<<count;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){

	int n,h,w;
	cin >> n>>h>>w;
	int cnt=0;
	rep(i,n){
		int a,b;
		cin >> a >> b;
		if (a>=h && b>=w) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    map<string,ll>m;
    ll sum=0;
    vector<ll>a(n+1);
    rep(i,n){
        string k;ll q;cin>>k>>q;
        a[i+1]=a[i]+q;
        m[k]=i+1;
    }
    string x;cin>>x;
    cout<<a[n]-a[m[x]]<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] v = new int[n];
        for (int i = 0; i< n; i++) {
            v[i] = sc.nextInt();
        }
        Arrays.sort(v);
        double tmp = v[0];
        for (int i = 1;i < n;i++) {
            double val = (v[i] + tmp) / 2;
            tmp = val;
        }
        System.out.println(tmp);
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String c = in.nextLine();
		if(c.matches("[aiueo]")) {
			System.out.println("vowel");
		}else {
			System.out.println("consonant");
		}
	}
}

Measured memory_bytes: 22868
#include <stdio.h>

int mode[100];

int main(void)
{
	
	int num, n, i;
	
	while (scanf("%d", &num) != EOF){
		
		mode[num]++;
	}
	for (i = 0; i < 100; i++){
		num = 0;
		for (n = 0; n < 100; n++){
			
			if (mode[i] >= mode[n]){
				num++;
			}
			if (num == 100){
				printf("%d\n", i);
			}
		}
	}
	return (0);
}
				

Measured memory_bytes: 596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 



int main(){
    int N;
    cin >> N;
    int num;
    if(N%2==0){
        num=N/2;
    }
    else{
        num=N/2+1;
    }
    cout << num;
} 

Measured memory_bytes: 256
def rotateX(dice):
    d1, d2, d3, d4, d5, d6 = dice
    return [d2, d6, d3, d4, d1, d5]


def rotateY(dice):
    d1, d2, d3, d4, d5, d6 = dice
    return [d4, d2, d1, d6, d5, d3]


def rotateZ(dice):
    d1, d2, d3, d4, d5, d6 = dice
    return [d1, d3, d5, d2, d4, d6]


def check():
    global n, s_count
    diff = [[0 for i in range(s_count)] for j in range(6)]
    for dice in color_list[:-1]:
        for i in range(6):
            if color_list[-1][i] != dice[i]:
                diff[i][dice[i]] += 1
    count = 0

    for c in diff:
        c_max = max(c)
        c_sum = sum(c)
        if n - c_max < c_sum:
            count += n - c_max
        else:
            count += c_sum

    return count


def solve(i):
    global ans
    if i == len(color_list) - 1:
        count = check()
        if ans > count:
            ans = count
    else:
        dice_memo = []
        for x in range(4):
            temp_dice = rotateX(color_list[i])
            for y in range(4):
                temp_dice = rotateY(temp_dice)
                for z in range(4):
                    temp_dice = rotateZ(temp_dice)
                    color_list[i] = temp_dice
                    if color_list[i] in dice_memo:
                        continue
                    dice_memo.append(color_list[i])
                    solve(i + 1)


while True:
    n = int(input())
    if n == 0:
        break

    memo = {}
    s_count = 0
    color_list = [[0 for j in range(6)] for i in range(n)]
    for i in range(n):
        for j, s in enumerate(input().split(" ")):
            if s not in memo:
                color_list[i][j] = memo.setdefault(s, s_count)
                s_count += 1
            else:
                color_list[i][j] = memo[s]

    if n == 1:
        print(0)
        continue
    ans = float("inf")
    solve(0)
    print(ans)



Measured memory_bytes: 5632
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	int n;
	int[] a;
	boolean[] have;
	boolean[] t;

	boolean dfs(int k, int rest) {
		if (rest == 0) {
			t = Arrays.copyOf(have, n);
			return greedy();
		}
		if (a[k] > rest)
			return false;
		have[k] = true;
		if (dfs(k + 1, rest - a[k]))
			return true;
		have[k] = false;
		return dfs(k + 1, rest);
	}

	boolean choice(int k, int rest) {
		if (rest == 0)
			return true;
		if (k < 0)
			return false;
		if (!t[k])
			return choice(k - 1, rest);
		if (a[k] <= rest) {
			t[k] = false;
			if (choice(k - 1, rest - a[k]))
				return true;
			t[k] = true;
		}
		return choice(k - 1, rest);
	}

	boolean greedy() {
		for (int i = 0; i < n - 1; i++) {
			if (!t[i]) {
				if (!choice(i - 1, a[i])) {
					return false;
				}
				t[i] = true;
			}
		}
		return true;
	}

	void run() {
		Scanner scanner = new Scanner(System.in);

		while (true) {
			n = scanner.nextInt();
			if (n == 0)
				break;
			a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = scanner.nextInt();
			}
			have = new boolean[n];
			have[0] = true;
			Arrays.sort(a);
			System.out.println(dfs(1, a[n - 1] - a[0]) ? "YES" : "NO");

		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 29268
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  vector<string> grid(100, string(100, '.'));
  for (int i = 0; i < 50; i++) {
    grid[i] = string(100, '#');
  }
  int h = 0, w = 0;
  for (int i = 0; i < a - 1; i++) {
    grid[h][w] = '.';
    if (w == 98) {
      w = 0;
      h += 2;
    } else {
      w += 2;
    }
  }
  h = 51;
  w = 0;
  for (int i = 0; i < b - 1; i++) {
    grid[h][w] = '#';
    if (w == 98) {
      w = 0;
      h += 2;
    } else {
      w += 2;
    }
  }
  cout << 100 << " " << 100 << endl;
  for (int i = 0; i < 100; i++) {
    cout << grid[i] << endl;
  }
}


Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = do
  { _  <- getInts
  ; xs <- getInts
  ; putInts (reverse xs)
  }

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



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

int ok;
int ng;
string s;
string ok_s;
bool isOK(int mid){
  int tmp=mid-ok;
  if(tmp%2==0){
    if(s==ok_s) return true;
    else  return false;
  }
  else{
    if(s==ok_s) return false;
    else  return true;
  }
}

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

  ok=0;
  ng=N;
  cout << 0 << endl;
  cin >> ok_s;
  if(ok_s=="Vacant")  return 0;

  while(1){
    int mid=(ok+ng)/2;
    cout << mid << endl;
    cin >> s;
    if(s=="Vacant") break;
    if(isOK(mid)){
      ok=mid;
      ok_s=s;
    }
    else ng=mid;
  }

  return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

int h[3],n,r;
int tp;

	while(cin >> h[0] >> h[1] >> h[2] ){
		if(h[0]==0 && h[1]==0 && h[2]==0 || cin.eof()) break;
		sort(h,h+3);
		int r2 = h[0]*h[0]+h[1]*h[1];
		cin >> n;
		rep(i,n){
			cin >> r;
			cout << (4*r*r>r2? "OK": "NA") << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1168
N = int(input())

current = (0, 0, 0)
for i in range(N):
  ct, cx, cy = map(int, current)
  t, x, y = map(int, input().split())

  v = abs(x-cx) + abs(y-cy)
  if abs(t-ct) < v:
    print("No")
    exit()

  if abs(t-ct) % 2 != v % 2:
    print("No")
    exit()

print("Yes")

  

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i,4){
    if(s[i] == '+'){
      ans++;
    }
    else{
      ans--;
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

int N;
int boss[7],height[7];

int get_boss(int id){
	if(boss[id] == id)return id;
	else{
		return boss[id] = get_boss(boss[id]);
	}
}

int is_same(int x,int y){
	return get_boss(x) == get_boss(y);
}

void unite(int x,int y){
	int boss_x = get_boss(x);
	int boss_y = get_boss(y);

	if(boss_x == boss_y)return;

	if(height[x] > height[y]){

		boss[boss_y] = boss_x;

	}else if(height[x] < height[y]){

		boss[boss_x] = boss_y;

	}else{ //height[x] == height[y]

		boss[boss_y] = boss_x;
		height[x]++;
	}
}

void init(){
	for(int i = 0; i < 7; i++){
		boss[i] = i;
		height[i] = 0;
	}
}

int main(){

	int array[7],num,num_KI,num_boss;

	char buf[3];
	int a,b;

	bool FLG;

	while(scanf("%d",&N) != EOF){

		init();
		for(int i = 0; i < 7; i++)array[i] = 0;

		for(int i = 0; i < N; i++){
			scanf("%s",buf);
			a = buf[0] - '0';
			b = buf[1] - '0';
			array[a]++;
			array[b]++;
			unite(a,b);
		}
		FLG = true;

		num_KI = 0;

		for(int i = 0; i < 7; i++){
			if(array[i]%2 == 1)num_KI++;
			for(int k = 0; k < 7; k++){
				if(array[i] != 0 && array[k] != 0 && get_boss(i) != get_boss(k)){
					FLG = false;
					break;
				}
			}
			if(!FLG)break;
		}

		if(num_KI > 2){
			printf("No\n");
			continue;
		}

		if(FLG){
			printf("Yes\n");
		}else{
			printf("No\n");
		}

	}

	return 0;
}

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

#define int long long

vector<int> a(200001);
map<int,int> m;

signed main() {
    //pref[r]-pref[l-1] = 0 -> pref[r] = pref[l-1]
    int n,ans = 0;
    cin >> n;
    int ss = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        ss += a[i];
       // cout << ss << " ";
        ans += m[ss]+(ss == 0);
        m[ss]++;
    //    cout << m[ss] << endl; 
    }
    cout << ans << endl;
    /*reverse(a.begin(),a.end());
    ss = 0;
    map<int,int> k;
    for(int i = 0;i < n;i++){
        ss += a[i];
        k[ss]++;
        ans += k[-ss];
    }*/
    //cout << ans;
	return 0;
}

Measured memory_bytes: 14336
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		long[] a = new long[n];
		for (i = 0; i < n; i++) {
			a[i] = parseLong(sc.next());
		}
		sc.close();
		Arrays.parallelSort(a);
		long ans=a[0];
		for (i = 1; i < n; i++) {
			if(ans==0) break;
			if(1000000000000000000L/ans<a[i]) {
				ans=-1;
				break;
			}
			ans*=a[i];
		}
		out.println(ans);
	}
}


Measured memory_bytes: 50592