akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strArray = new String[2];
    StringBuilder sb = new StringBuilder();
    String line;
    while (true) {
      line = br.readLine();
      strArray = line.split(" ");
      int h = Integer.parseInt(strArray[0]);
      int w = Integer.parseInt(strArray[1]);
      if(h == 0 && w == 0) {
        break;
      }
      for (int i = 0;i < h;i++) {
        if (i == 0 || i == (h - 1)) {
          for (int f = 0;f < w;f++) {
            sb.append("#");
          }
        }
        else {
          for (int f = 0;f < w;f++) {
            if (f == 0 || f == (w - 1)) {
              sb.append("#");
            }
            else {
              sb.append(".");
            }
          }
        }
        sb.append("\n");
      }
      sb.append("\n");
    }
    System.out.print(sb);
  }
}

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

int main()
{
  int N ;
  cin>>N ;
  vector<int>h(N+1) ;
  for(int i=0;i<N;i++) cin>>h.at(i) ;
  h.at(N)=0 ;
 
  int min=0 ;
  int min_h=1e9 ;
  int begin=0 ;
  int end=0 ;
  while(begin!=N){
    min_h=1e9 ;
    for(end=begin;h.at(end)!=0&&end!=N;end++) if(min_h>h.at(end)) min_h=h.at(end) ;
    if(min_h!=1e9){
      min+=min_h ;
      for(int i=begin;i<end;i++) h.at(i)-=min_h ;
    }else begin++ ;
  }

    
  cout<<min<<endl ;
  
  return 0 ;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    ll A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
    if(A+B < 2*C){
        cout << A*X + B*Y << endl;
    }else{
        ll res = 0;
        res += 2*C*min(X, Y);
        if(X-Y > 0){
            if(A > 2*C){
                res += 2*C*(X-Y);
            }else{
                res += A*(X-Y);
            }
        }else{
            if(B > 2*C){
                res += 2*C*(Y-X);
            }else{
                res += B*(Y-X);
            }
        }
        cout << res << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   1e9  ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
    int n ;
    cin >> n ;
    vector < int > a(n) ;
    for( int i = 0 ; i < n-1 ; i++){
        int x ;
        cin >> x ;
        x--;
        a[x]++;
    }
    for( int i = 0 ; i < n ; i++) cout << a[i] << "\n" ;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t = 1 ;
    //cin >> t ;
    int cnt = 1 ;
    while(t--){
       // cout << "Case #" << cnt << ": ";
        solve( );
        cnt++;
    }
}


Measured memory_bytes: 3996
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<vector<int>> v(2,vector<int> (n+1,0));
    rep(i,2){
        rep(j,n) cin >> v[i][j];
    }
    vector<vector<int>> dp(2,vector<int>(n+1,0));
    dp[0][0] = v[0][0];
    for(int i = 0;i < 2; i++){
        for(int j = 0; j < n; j++){
           if(i==0 && j!=0) dp[i][j] = dp[i][j-1] + v[i][j];
           else if(j!=0 && i==1) dp[i][j] = max(dp[i-1][j],dp[i][j-1]) + v[i][j];
           else if(i==1) dp[i][j] = dp[i-1][j] + v[i][j];
        }
    }
    cout << dp[1][n-1] << endl;
    return 0;
}

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

int main(){
	int a[3];
  	cin>>a[0]>>a[1]>>a[2];
  sort(a,a+3);
  	if(a[0]==5&&a[1]==5&&a[2]==7){
    cout<<"YES"<<endl;}
  else{
    cout<<"NO"<<endl;
  }
  
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,a,b = LI()
    print(min(n*a,b))
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 39152
#include <iostream>
#include <string>
#include <cmath>
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
	  int N;
    ll M,a,ans=0;
		cin>>N>>M;
    priority_queue<ll> queue;

		for (int i = 0; i < N; ++i) {
		  cin>>a;
			queue.push(a);
		}

    ll x;
    for (int i = 0; i < M; ++i) {
      x=queue.top();
      queue.pop();
      queue.push(x/2);
    }

    for (int i = 0; i < N; ++i) {
      ans+=queue.top();
      queue.pop();
    }

      cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans=0,n;
    cin>>n;
    vector<ll> p(n+10,0);
    ll minv=MAX;
    for(int i=0;i<n;i++){
        cin>>p[i];
        //p[i]-=1;
        if(minv>p[i]){
            ans++;
            minv=p[i];
        }
    }

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 1792
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

int main(){
    string a , b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = 0; i < 3; i++){
        cnt += a[i] == b[i];
    }
    cout << cnt << endl;
}


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

int main(int argc, char const *argv[])
{
	int a, b, q; cin >> a >> b >> q;
	vector<ll> s(a); rep(i, a) cin >> s[i];
	vector<ll> t(b); rep(i, b) cin >> t[i];
	vector<ll> x(q); rep(i, q) cin >> x[i];

	rep(i, q) {
		int idx0 = lower_bound(s.begin(), s.end(), x[i]) - s.begin();
		int idx1 = lower_bound(t.begin(), t.end(), x[i]) - t.begin();
		// printf("idx %d %d \n", idx0, idx1);
		ll ans = INFF;
		for (int j = max(0, idx0 - 1); j < min(a, idx0 + 2); ++j) {
			for (int k = max(0, idx1 - 1); k < min(b, idx1 + 2); ++k) {
				ans = min(ans, abs(x[i] - s[j]) + abs(s[j] - t[k]));
				ans = min(ans, abs(x[i] - t[k]) + abs(t[k] - s[j]));
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r; cin >> r;
  cout << r*r << "\n";
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 104
#define K 100004
#define INF 1e9+7

using namespace std;

ll n,k,ar[N],mod=1e9+7;
ll pre[K],dp[K];

ll get_sum(ll i,ll j)
{
    if(i == 0)
        return pre[j];
    return (pre[j] - pre[i-1]+mod)%mod;
}

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

    cin >> n >> k;

    rep(i,0,n)
    {
        cin >> ar[i];
    }

    rep(j,0,k+1)
    {
        if(j <= ar[0])
            dp[j] = 1;
        else
            dp[j] = 0;

        if(j == 0)
            pre[j] = dp[j];
        else
            pre[j] = (pre[j-1]+dp[j])%mod;
    }

    rep(i,1,n)
    {
        rep(j,0,k+1)
        {
            dp[j] = get_sum(max((ll)0,j-ar[i]),j);
        }

        rep(j,0,k+1)
        {
            if(j == 0)
                pre[j] = dp[j];
            else
                pre[j] = (pre[j-1]+dp[j])%mod;
        }
    }

    cout << dp[k];

    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cctype>
#include <utility>
#include <cmath>
#include <algorithm>
using namespace std;

const auto gcu = getchar_unlocked;
const auto pcu = putchar_unlocked;
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _sc _il bool scan
_T T in(int c){T n=0;int m=1;while(isspace(c)){c=gcu();}if(c=='-')m=-1,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
_il int in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _ot _il void out
#define _ol _il void outl
_ot(bool b) {pcu('0'+b);}
_ot(const char *s){while(*s)pcu(*s++);}
_ot(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_ot(string s){for(char c:s)pcu(c);}
#endif
_T _ot(T n){static char b[20];char *p=b,m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=n%10*m+'0',n/=10;while(p!=b)pcu(*--p);}
_ol(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _ot(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _ot(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _ol(T&&... t){out(move(t)...);outl();}

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	sieve() : s(), v() {
		for (int i = 0; i < N; i++)
			s[i] = true;
		for (int i = 4; i < N; i += 2)
			s[i] = false;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	sieve<1300000> s;
	for (int n; (n = in());) {
		if (s.s[n])
			outl(0);
		else {
			auto i = lower_bound(s.v, s.v + s.l, n);
			outl(*i - *(i - 1));
		}
	}
}


Measured memory_bytes: 8772
#include<stdio.h>

int main(void){
  int i,j;
  int n,renum,a[20],c[20];
  int p,g,diff,mindiff;

  for(;;){
    scanf("%d",&n);
    if(n==0)
      break;

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

    renum=1;
    mindiff=0;
    for(i=0;i<n;i++){
      renum*=2;
      c[i]=0;
      mindiff+=a[i];
    }

    for(i=0;i<=renum/2;i++){
      p=0;
      g=0;
      for(j=0;j<n;j++){
        if(c[j]==0)
          p+=a[j];
        else
          g+=a[j];
      }

      diff=(p>=g)?p-g:g-p;
      if(mindiff>diff)
        mindiff=diff;
      
      if(mindiff==0)
        break;

      c[0]++;
      for(j=0;j<n-1;j++)
        if(c[j]>=2){
          c[j+1]+=c[j]/2;
          c[j]%=2;
        }
    }

    printf("%d\n",mindiff);
  }

  return 0;
}

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

#define INF 99999999
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

using namespace std;

int main(void){
    int N,M;
    cin >> N >> M;
    int roads[N];
    
    REP(i,N)roads[i] = 0;
    
    REP(i,M){
        int a,b;
        cin >> a >> b;
        a--;b--;
        
        roads[a]++;
        roads[b]++;
        
    }
    
    REP(i,N){
        cout << roads[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, s;
    long long mod = 998244353;
    cin >> n >> s;
    vector<long long>v(n + 3);
    for(int i = 1; i <= n; i++){
        cin >> v[i];
    }
    long long dp[n + 3][s + 3];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= s; j++){
            dp[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        dp[i][0] = i + 1;
        for(int j = 1; j <= s; j++){
            dp[i][j] = dp[i - 1][j];
        }
        for(int j = v[i]; j <= s; j++){
            dp[i][j] = (dp[i][j] + dp[i - 1][j - v[i]]) % mod;
        }
    }
    long long ans = 0;
    for(int i = 0; i <= n; i++){
        ans = (ans + dp[i][s]) % mod;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 73976
#include <iostream>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;
const int N=100500;
pair<int,int> a[N];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i].first;
		a[i].second=i+1;
	 } 
	sort(a,a+n);
	cout<<a[0].second;
	for(int i=1;i<n;i++)
		cout<<" "<<a[i].second;
	return 0;
 } 

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define N 100001
using namespace std;
int n;
double pw,vw[N],pf[N],vf[N],th[N];
const double EPS = 1e-14;

double f(double x){
  double cost=x*pw;
  for(int i=0;i<n;i++){
    double v = th[i]-x*vw[i];
    if(v>0)cost+=pf[i]*(v/vf[i]);
  }
  return cost;
}

double search(){
  double L=0,R=101;
  while(abs(L-R)>EPS){
    double M1=(L+(R-L)/3);
    double M2=(L+2*(R-L)/3);
    if(f(M1)<f(M2))R=M2-EPS;
    else L=M1+EPS;
  }
  return L;
}


int main(){
  while(cin>>n,n){
    cin>>pw;
    for(int i=0;i<n;i++)cin>>vw[i]>>pf[i]>>vf[i]>>th[i];
    printf("%.15f\n",f(search()));
  }
  return 0;
}

Measured memory_bytes: 6312
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
const int N = 105;
const int INF = 0x3f3f3f3f;
typedef long long ll;
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1

int A[N];
int main() {
	int n;
	while(~scanf("%d", &n)) {
		for(int i = 0; i < n; ++i) {
			scanf("%d", &A[i]);
		}
		int ans = 0;
		int cnt = 1;
		for(int i = 1; i < n; ++i) {
			if(A[i] == A[i-1]) {
				cnt ++;
			} else {
				ans += cnt / 2;
				cnt = 1;
			}
		}
		ans += cnt / 2;
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
const long long MOD = 1e9 + 7, INF = 1e18;
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;}
 
 
 
signed main(){
	int N;
	cin>>N;
	vector<vector<int>>a(N,vector<int>(N-1));
	set<pair<int,int>>flg;
	vector<int>to(N,-1);
	REP(i,N)REP(j,N-1){
		cin>>a[i][j];
		a[i][j]--;
		if(j == 0){
			to[i] = a[i][j];
		}
	}
	vector<int>now(N,0);
	REP(i,N){
		if(to[to[i]] == i){
			flg.insert({min(i,to[i]),max(i,to[i])});
		}
	}
	vector<int>day(N,0);
	while(!flg.empty()){
		auto p = *flg.begin();
		flg.erase(flg.begin());
		int ma = max(day[p.first],day[p.second]);
		day[p.first] = day[p.second] = ma + 1;
		now[p.first]++;
		now[p.second]++;
		if(now[p.first]<N-1)to[p.first] = a[p.first][now[p.first]];
		if(now[p.second]<N-1)to[p.second] = a[p.second][now[p.second]];
		if(now[p.first]<N-1&&to[to[p.first]] == p.first)flg.insert({min(p.first,to[p.first]),max(p.first,to[p.first])});
		if(now[p.second]<N-1&&to[to[p.second]] == p.second)flg.insert({min(p.second,to[p.second]),max(p.second,to[p.second])});
	}
	int ok = 1;
	REP(i,N)if(now[i]!=N-1)ok = 0;
	int ma = 0;
	REP(i,N)CHMAX(ma,day[i]);
	if(ok)cout<<ma<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 8192
from itertools import groupby
d = {"R": "L", "L": "R"}
N, K = map(int, input().split())
S = input()
A = [(s,len(list(it))) for s, it in groupby(S)]
A = [(d[s], l) if i & 1 and i//2 < K else (s, l) for i, (s, l) in enumerate(A)]
S = "".join(s*l for s, l in A)
print(N - len(list(groupby(S))))

Measured memory_bytes: 21488
#include <bits/stdc++.h>
#define rep(i, n) REP(i, 0, n)
#define REP(i, l, r) for (long long i = l; i < r; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
int gcd(int a, int b) {
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int lcm(int a, int b) {
	return a * b / gcd(a, b);
}
bool prime(int a) {
	if (a == 1) return false;
	for (int i = 2; i * i <= a; i++) {
		if (a % i == 0) return false;
	}
	return true;
}
signed main() {
	int s;
	cin>>s;
	bool a=false,b=false;
	if(s/100!=0&&s/100<=12)a=true;
	if(s%100!=0&&s%100<=12)b=true;
	if(a&&b)cout<<"AMBIGUOUS"<<endl;
	else if(a)cout<<"MMYY"<<endl;
	else if(b)cout<<"YYMM"<<endl;
	else cout<<"NA"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    int res = 0;
    rep(i, n) {
        int l, r;
        cin >> l >> r;
        res += r - l + 1;
    }
    cout << res << endl;
    return 0;
}

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


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

    sort(X.begin(), X.end());
    rep(i, N) X[i] -= A;

    vector<int> L, R;
    int n_zero = 0;
    for (auto x : X) {
        if (x < 0) {
            L.push_back(x);
        } else if (x > 0) {
            R.push_back(x);
        } else {
            n_zero++;
        }
    }

    const int M = 50 * 50 + 1;
    vector<ll> S_L(M, 0);
    for (auto l : L) {
        l = -l;
        for (int i = M; 1 <= i - l; i--) {
            S_L[i] += S_L[i - l];
        }
        S_L[l]++;
    }

    vector<ll> S_R(M, 0);
    for (auto r : R) {
        for (int i = M; 1 <= i - r; i--) {
            S_R[i] += S_R[i - r];
        }
        S_R[r]++;
    }

    ll n_comb = 0;
    rep(i, M) n_comb += S_L[i] * S_R[i];

    ll ans = (n_comb + 1) * pow(2, n_zero) - 1;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4068
n = gets.to_i()
    arr = gets.split().map{|item| item.to_i}
    s = arr.inject(:+)


    result = true
    arr.each do  |i|
      result = result & (s > 2 *i )
    end
     
    if result
      puts "Yes"
    else
      puts "No"
    end

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

int main(){
    string s;
    cin >> s;
    if(s == "RRR") cout << 3 << endl;
    else if(s == "RRS") cout << 2 << endl;
    else if(s == "RSR") cout << 1 << endl;
    else if(s == "SRR") cout << 2 << endl;
    else if(s == "SSR") cout << 1 << endl;
    else if(s == "SRS") cout << 1 << endl;
    else if(s == "RSS") cout << 1 << endl;
    else if(s == "SSS") cout << 0 << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define start_routine cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int begtime = clock();
#define end_routine int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0;
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define int long long
#define mp make_pair
#define fr(i,a,b) for(i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("C:/Users/Aman/Desktop/kachda/input.txt", "r", stdin); freopen("C:/Users/Aman/Desktop/kachda/output.txt", "w", stdout);

using namespace std;
int a[100001], b[100001], c[100001];
int dp[100001][3];

signed main()
{
	//FILEIO
 	start_routine
	
	int n;
	cin>>n;
	int i;

	fr(i,1,n + 1)
	{
		cin>>a[i]>>b[i]>>c[i];
	}

	dp[1][0] = a[1], dp[1][1] = b[1], dp[1][2] = c[1];

	fr(i,2,n + 1)
	{
		int j;
		fr(j,0,3)
		{
			if(j == 0)
			{
				dp[i][j] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
			}
			if(j == 1)
			{
				dp[i][j] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
			}
			if(j == 2)
			{
				dp[i][j] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
			}
		}
	}

	cout<<max(dp[n][0], max(dp[n][1], dp[n][2]));
 	end_routine
}

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

using namespace std;

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int left = -1;
    int ans = 0;
    int sum = -1;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(left < a[i]){
            sum = 0;
        }else{
            sum++;
        }
        left = a[i];
        ans = max(ans, sum);
        //cout << sum << " " << ans << " " << left << endl;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	// sengen
	int n,m;
	// nyuryoku
	cin >> n >> m;
	vector<string> s(m);
	int p[m];
	for(int i=0;i<m;i++){
		cin >> p[i] >> s[i];
	}
	int ac[n] = {};
	int wa[n] = {};
	// keisan
	for(int i=0;i<m;i++){
		if(s[i] == "AC"){
			ac[p[i]-1]++;
		}
		if(s[i] == "WA" && ac[p[i]-1] == 0){
			wa[p[i]-1]++;
		}
	}
	int acsum=0,wasum = 0;
	for(int i=0;i<n;i++){
		if(ac[i] > 0){
			acsum++;
		}
		if(wa[i] > 0 && ac[i] > 0){
			wasum += wa[i];
		}
	}
	// syutsuryoku
	cout << acsum << ' ' << wasum;
}

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

int main()
{
  int n;
  while( cin >> n, n ) {
    string s;
    cin >> s;
    int A[101], B[101];

    for(int i=0; i<n; i++) {
      int a, b;

      cin >> a >> b;
      a--; b--;
      A[i] = a;
      B[i] = b;
    }

    for(int i=n-1; i>=0; i--) {
      int a = A[i], b = B[i];
      int dif = abs(a - b);
      char tmp = s[a];
      s[a] = s[b];
      s[b] = tmp;
      for(int i=0; i<dif; i++) {
	if( s[a] == 'z' ) {
	  s[a] = 'a';
	} else s[a]++;

	if( s[b] == 'z' ) {
	  s[b] = 'a';
	} else s[b]++;
	
      }
    }

    cout << s << endl;
  }
}

Measured memory_bytes: 3136
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(v) (v).begin(), (v).end()
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

class Point
{
	public:
	Point()
	{
		x = 0.0;
		y = 0.0;
	}
	Point(double xx, double yy)
	{
		x = xx;
		y = yy;
	}
	double x;
	double y;
};

void Koch(int n, Point st, Point ed)
{
	if (n==0)
		return;
	
	Point s;
	Point u;
	Point t;
	
	s.x = (ed.x + (2 * st.x))/3.0;
	s.y = (ed.y + (2 * st.y))/3.0;
	
	t.x = ((2 * ed.x) + st.x)/3.0;
	t.y = ((2 * ed.y) + st.y)/3.0;
	
	double rad = PI / 180 * 60;

	u.x = (t.x - s.x) * cos(rad) - (t.y - s.y) * sin(rad) + s.x;
	u.y = (t.x - s.x) * sin(rad) + (t.y - s.y) * cos(rad) + s.y;
	
	Koch(n-1, st, s);
	cout << s.x << " " << s.y << endl;
	Koch(n-1, s, u);
	cout << u.x << " " << u.y << endl;
	Koch(n-1, u, t);
	cout << t.x << " " << t.y << endl;
	Koch(n-1, t, ed);
	
}

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	
	Point st = Point(0.0, 0.0);
	Point ed = Point(100.0, 0.0);
	
	cout << fixed << setprecision(8);
	cout << st.x << " " << st.y << endl;
	Koch(n, st, ed);
	cout << ed.x << " " << ed.y << endl;
	
	return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll arr[100009];
int main()
{
    ll n;
    cin>>n;
    ll sum=0;
    for(int i=0; i<n; i++)
        {cin>>arr[i];sum+=arr[i];}
    if(sum%2==0)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/



int n;
int a[114];
signed main() {
	cin >> n;
	rep(i, n)a[i] = inf;
	rep(i, n - 1) {
		int b; cin >> b;
		chmin(a[i], b);
		chmin(a[i + 1], b);
	}
	int ans = 0;
	rep(i, n) {
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int N,M; cin>>N>>M;
  int sum=1;
  vi A(N);
  rep(i,0,N){
    cin>>A[i];
    sum=sum*A[i]/__gcd(sum,A[i]);
  }
  int ans=M/(sum/2)-M/sum;
  int memo=0;
  while(A[0]%2==0){
    memo++;
    A[0]/=2;
  }
  rep(i,1,N){
    int sum=0;
    while(A[i]%2==0){
      sum++;
      A[i]/=2;
    }
    if(sum!=memo) ans=0;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int g[6][6][4]={};//top,bottom,left,right

int main(void) {
  int i,j;
  rep(i,9){
    string s;
    cin>>s;
    if(i%2){
      rep(j,5){
        g[i/2+1][j][3] = s[j] - '0';
        g[i/2+1][1+j][2] = g[i/2+1][j][3];
      }
    }else{
      rep(j,4){
        g[i/2+1][1+j][0] = s[j] - '0';
        g[i/2][1+j][1] = g[i/2+1][1+j][0];
      }
    }
  }

  char s[5] = {"LRDU"};
  int dx[4] = {0,0,1,-1};
  int dy[4] = {-1,1,0,0};

  int x=0,y=1,z=1;//(x,y)右手がz

  while(x+y){
    if(g[x][y][z]){
        cout<<s[z];
        if((z==1 && g[x][y][1] && g[x][y][3]) || (z==0 && g[x][y][0] && g[x][y][2]) ||
          (z==2 && g[x][y][2] && g[x][y][1]) || (z==3 && g[x][y][3] && g[x][y][0])){
            switch(z){
              case 0: z=2;break;
              case 1: z=3;break;
              case 2: z=1;break;
              case 3: z=0;break;
            }
        }else{
          x = x + dx[z];
          y = y + dy[z];
        }
    }else{
      switch(z){
        case 0: z=3;x--;break;
        case 1: z=2;x++;break;
        case 2: z=0;y--;break;
        case 3: z=1;y++;break;
      }
    }
  }
    cout<<endl;
}



Measured memory_bytes: 3040
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
typedef vector<int> vi;
const int MAX=1e5+5;

//後手が勝つか
bool dp[MAX];

int main(){
	int N,K;
	cin>>N>>K;
	int a[100];
	rep(i,N)cin>>a[i];
	
	dp[0]=true;
	rep1(i,K){
		bool f=true;
		rep(j,N){
			if(a[j]<=i&&dp[i-a[j]])f=false;
		}
		dp[i]=f;
	}
	if(dp[K])cout<<"Second";
	else cout<<"First";
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <cstdio>
#include <iomanip>
#include <tuple>
#include <stack>
using namespace std;
typedef long long ll;

int main(){
    ll a,b,c,d,e,k,l,m,n,o=0,p,q,r,z,max1=0,ans=0,mina=100000000,minb=100000000;
    string s,t,u;
    cin>>a>>b>>m;
    ll aa[a],bb[b],cc[m],x[m],y[m];
     for(ll i=0;i<a;i++){
        cin>>aa[i];
        mina=min(mina,aa[i]);
     }
     for(ll i=0;i<b;i++){
        cin>>bb[i];
         minb=min(minb,bb[i]);
     }
    for(ll i=0;i<m;i++){
        cin>>x[i]>>y[i]>>cc[i];
     }
    ll minab=mina+minb;
        
    for(ll i=0;i<m;i++){
        if(aa[x[i]-1]+bb[y[i]-1]-cc[i]<minab)minab=aa[x[i]-1]+bb[y[i]-1]-cc[i];
     }
    cout<<minab<<endl;
}




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

int main() {
    string s,t;
    cin >> s >> t;
    int ls = s.length();
    int lt = t.length();

    int ans = 1000000;
    for(int i=0; i<ls-lt+1; i++){
        int cnt = 0;
        for(int j=0; j<lt; j++){
            if(s[i+j] != t[j]) cnt++;
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		long MOD=1000000007L;

		Scanner sc = new Scanner(System.in);

		long L=sc.nextLong();
		long R=sc.nextLong();
		int l=(int)L%2019;
		int r=(int)R%2019;
		int ans=2018;

		if((int)L/2019 != (int)R/2019)System.out.println(0);
		else{
			for(int i=l;i<r;++i){
				for (int j=l+1;j<=r;++j){
					ans=Math.min(ans, (i*j)%2019);
				}
			}
			System.out.println(ans);
		}

	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//

int main(){
   ll n;cin>>n;
   ll ans=0;
   FOR(i,1,n){
      ll a;cin>>a;
      if(i%2==1 && a%2==1)ans++;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3632
N,M = map(int,input().split())

H = list(map(int,input().split()))

H_peak = list()
for i in range(N):
    H_peak.append(list())

for i in range(M):
    A,B = map(int,input().split())
    H_peak[A-1].append(B)
    H_peak[B-1].append(A)

good = 0
flag = 1
for i in range(N):
    for j in H_peak[i]:

        if H[i] <= H[j-1]:
            flag = 0
    if flag == 1:

        good += 1
    flag = 1


print(good)

Measured memory_bytes: 29348
# -*- coding: utf-8 -*-
import sys,copy,math,heapq,itertools as it,fractions,re,bisect,collections as coll

N = int(raw_input())

s = 0
ans = []
for i in xrange(1, N + 1):
	ans.append(i)
	s += i
	if s >= N:
		k = s - N
		break

for i in ans:
	if i == k: continue
	print i


Measured memory_bytes: 4520
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */
int maxSubarrayXOR(std::vector<int> set, int n) 
{ 
    int index = 0; 
    for (int i = 64-1; i >= 0; i--) 
    { 
        int maxInd = index; 
        int maxEle = LLONG_MIN; 
        for (int j = index; j < n; j++) 
        { 
            if ( (set[j] & (1ll << i)) != 0  
                     && set[j] > maxEle ) 
                maxEle = set[j], maxInd = j; 
        } 
        if (maxEle == LLONG_MIN) 
        continue; 
		std::swap(set[index], set[maxInd]); 
  
        maxInd = index; 
  
        for (int j=0; j<n; j++) 
        { 
            if (j != maxInd && 
               (set[j] & (1ll << i)) != 0) 
                set[j] = set[j] ^ set[maxInd]; 
        } 
  
        index++; 
    } 
  
    int res = 0; 
    for (int i = 0; i < n; i++) 
        res ^= set[i]; 
    return res; 
} 

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	int xorsum = 0;
	rep(i,n) {
		int x;
		std::cin >> x;
		xorsum ^= x;
		a[i] = x;
	}
	int sum = xorsum;
	rep(i,n) {
		a[i] &= ~xorsum;
	}
	sum+=2*maxSubarrayXOR(a,n);
	print(sum);

	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int dif(int a,int b){
  if(a>b){
    return a-b;
  }else{
    return b-a;
  }
}

int main(){
  int ad,bd,x,a,b;
  scanf("%d %d %d",&x,&a,&b);
  ad = dif(x,a);
  bd = dif(x,b);
  if(ad>bd){
    printf("B\n");
  }else{
    printf("A\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<string,int> mp;
int ind[1001],par[1001];
bool ko(int a,int b){
  return par[a]==b;
}

bool sos(int a,int b){
  while(a!=b&&a)
    a=par[a];
  return a==b;
}

int main(){
  int n,m,T=0;
  string s;
  while(cin>>n>>m,n){
    getline(cin,s);
    memset(ind,0,sizeof(ind));
    memset(par,0,sizeof(par));
    mp.clear();
    par[0]=-1;
    for(int i=0;i<n;i++){
      int k;
      getline(cin,s);
      for(k=0;s[k]==' ';k++);
      s=s.substr(k,s.size()-k);
      mp[s]=i;
      ind[i]=k;
      for(int j=i-1;j>=0;j--)
	if(ind[j]<k){par[i]=j;break;}
    }
    for(int i=0;i<m;i++){
      string q[6];
      for(int j=0;j<6;j++)cin>>q[j];
      bool ans;
      q[5]=q[5].substr(0,q[5].size()-1); 
      int a=mp[q[0]],b=mp[q[5]];
      if(q[3]=="child")ans=ko(a,b);
      if(q[3]=="parent")ans=ko(b,a);
      if(q[3]=="sibling")ans=(par[a]==par[b]);
      if(q[3]=="descendant")ans=sos(a,b);
      if(q[3]=="ancestor")ans=sos(b,a);
      if(ans)cout<<"True"<<endl;
      else cout<<"False"<<endl;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 3312
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<string>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<limits.h>
#define rep(i,n) for(ll i = 0; i < (ll)n; i++)
#define swap(a,b) a^=b;b^=a;a^=b;
#define chmax(a,b) {if(a < b) a = b;}
#define chmin(a,b) {if(a > b) a = b;}
using namespace std;
typedef long long ll;
ll gcd(ll, ll);
vector<bool> to_binary(int);
int sum(vector<int>);
int min(vector<int>);
int max(vector<int>);
ll nCr(ll n, ll r);

const ll INF = 1LL << 60;

typedef tuple<ll, ll> mtupl;

bool mycomp(mtupl x, mtupl y) {
	return get<1>(x) < get<1>(y);
}

vector<vector<ll>> memo;

ll get(int x, int y) {
	if (memo[x][y] != -1)
		return memo[x][y];

	if (x == 0) return 1;
	if (y < x) return 0;

	memo[x][y] = get(x, y - 1) + get(x - 1, y - 1);
	return memo[x][y];
}

ll mpow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; i < b; i++) {
		ans *= a;
		ans %= 1000000007;
	}
	return ans;
}

int N, D;

int solve(vector<ll> a, vector<ll> b) {
	int sum = 0;
	rep(i, D) {
		sum += pow(a[i] - b[i],2);
	}

	int test = sqrt(sum);
	return (test * test == sum) ? 1 : 0;
}


int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//Program Start	

	cin >> N >> D;

	vector<vector<ll>> X(N);

	rep(i, N) {
		X[i].resize(D);
		rep(j, D) {
			cin >> X[i][j];
		}
	}

	int ans = 0;

	for(int i = 0;i < N;i++) {
		for(int j = i + 1;j < N;j++) {

			//cout << to_string(i) + ":" + to_string(j) + "=" + to_string(solve(X[i], X[j])) << endl;;

			//printf("%d %d %d %d %d\n", i, j, solve(X[i], X[j]));

			ans += solve(X[i], X[j]);
		}
	}

	cout << ans << endl;


	/* ABC 125_c
	int N;
	cin >> N;

	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	vector<ll> Forward(N), Backward(N);
	Forward[0] = A[0];
	int tmp = A[0];
	for (int i = 1; i < N; i++) {
		tmp = gcd(tmp, A[i]);
		Forward[i] = tmp;
	}

	tmp = A[N - 1];
	Backward[N - 1] = tmp;
	for (int i = N - 2; i >= 0; i--) {
		tmp = gcd(tmp, A[i]);
		Backward[i] = tmp;
	}
	*/


ProgramEndPointLabel:;

	//Program End
	system("pause");

	return 0;
}

ll nCr(ll n, ll r) {
	ll res = 1;
	for (int i = 0; i < r; i++) {
		res *= (n - i);
	}
	for (int i = 1; i <= r; i++) {
		res /= i;
	}
	return res;
}

int vsum(vector<int> v) {
	int res = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		res += *it;
	return res;
}
int vmin(vector<int> v) {
	int min = INT32_MAX;
	for (auto it = v.begin(); it != v.end(); it++)
		min = std::min(min, *it);
	return min;
}
int vmax(vector<int> v) {
	int max = 0;
	for (auto it = v.begin(); it != v.end(); it++)
		max = std::max(max, *it);
	return max;
}

ll gcd(ll A, ll B) {
	int r = A % B;
	while (r != 0) {
		A = B;
		B = r;
		r = A % B;
	}

	return B;
}

vector<bool> to_binary(int x) {
	vector<bool> res;
	while (x != 0) {
		res.push_back(x % 2);
		x /= 2;
	}
	return res;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
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<<"	";
    }
    return s;
}

// 2 dimentional vector
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 main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    cin>>s;
    ll n = s.length();
    ll ans= n*(n-1)/2+1;
    Vec v(26);
    rep(i,n){
        v[s[i]-'a']++;
    }
    rep(i,26){
        ll &x = v[i];
        ans -= x*(x-1)/2;
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 720
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int N, X; cin >> N >> X;

  int total = 0;
  vector<int> M(N);
  for (int i = 0; i < N; i++) {
    cin >> M[i];
    total += M[i];
  }

  sort(M.begin(), M.end());
  
  cout << (X-total)/M[0] + N << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

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

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

    int x;
    cin >> x;
    cout << (x == 0) << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;

int N, K;
const int MOD = 1.0e9 + 7;

ll pow_mod(ll n, ll k, ll mod) {
    if (k == 0) return 1;
    else if (k % 2 == 1) {
        return pow_mod(n, k-1, mod) * n % mod;
    }
    else {
        ll tmp = pow_mod(n, k/2, mod);
        return tmp * tmp % mod;
    }
}

ll neg_mod(ll n, ll mod)  {
    ll res = n % mod;
    if (res < 0) res += mod;
    return res;
}

vector<ll> divisor(ll n) {
    vector<ll> ret;
    for (ll i = 1; i*i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) {
                ret.push_back(n/i);
            }
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

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

    vector<ll> pm_vec(K+1);
    for (int i = 1; i <= K; i++) {
        pm_vec[i] = pow_mod(K/i, N, MOD);
    }

    for (int i = K; i >= 1; i--) {
        vector<ll> div = divisor(i);
        for (int j = 0; j < div.size() - 1; j++) {
            pm_vec[div[j]] = neg_mod(pm_vec[div[j]] - pm_vec[i], MOD);
        }
    }    

    ll ans = 0;
    for (int i = 1; i <= K; i++) {
        ans = (ans + (i * pm_vec[i]) % MOD) % MOD;
    }

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

Measured memory_bytes: 4052
a,b,c,x,y = map(int, input().split())
ans = 0
if x>y:
    z,d = x-y,a
else:
    z,d = y-x,b
if a+b > c*2:
    ans += min(x,y)*2*c
    if d > c*2:
        ans += z*2*c
    else:
        ans += z*d
else:
    ans += a*x + b*y

print(ans)

Measured memory_bytes: 3064
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  char c;
  cin >> c;
  if(c >= 'A' && c <= 'Z') cout << 'A' << endl;
  else cout << 'a' << endl;
  return 0;
}


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

using namespace std;

typedef long long int64;

int main()
{
  int64 K;
  cin >> K;


  vector< int64 > vs(50, 50);
  vector< vector< int64 > > st;
  while(*max_element(begin(vs), end(vs)) >= 50) {
    auto p = *max_element(begin(vs), end(vs));
    for(int i = 0; i < vs.size(); i++) {
      if(vs[i] == p) {
        vs[i] -= 51;
        break;
      }
    }
    for(int i = 0; i < vs.size(); i++) {
      vs[i]++;
    }
    st.push_back(vs);
  }
  reverse(begin(st), end(st));


  if(K <= 100) {
    int64 sub = 1 + K / 2;
    if(K % 2 == 0) {
      cout << 2 << endl;
      cout << sub << " " << sub << endl;
    } else {
      cout << 2 << endl;
      cout << sub - 1 << " " << sub + 2 << endl;
    }
    return (0);
  }

  vector< int64 > stt;
  cout << 50 << endl;
  for(int i = 0; i < 50; i++) {
    cout << st[K % 50][i] + K / 50 << " ";
  }
  cout << endl;

}

Measured memory_bytes: 256