akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long int ll;
const int MAXN=1001;
int n,place;
int fa[MAXN],opt[MAXN],tot=0;
ll arr[MAXN],dp[MAXN],ans=0;
bool flag=true;
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>arr[i];
		dp[i]=arr[i];
		if(arr[i]>0) flag=false;
	}
	if(flag){
		ans=-1e9-1;
		for(int i=1;i<=n;++i){
			if(arr[i]>ans){
				ans=arr[i];
				place=i;
			}
		}
		for(int i=n;i>place;--i) opt[++tot]=i;
		for(int i=1;i<place;++i) opt[++tot]=1;
		cout<<ans<<endl<<tot<<endl;
		for(int i=1;i<=tot;++i) cout<<opt[i]<<endl;
	}
	else{
		for(int i=1;i<=n;++i)
		for(int j=1;j<i;++j)
			if(((i-j)&1)==0){
				if(dp[j]+arr[i]>dp[i]){
					dp[i]=dp[j]+arr[i];
					fa[i]=j;
				}
			}
	for(int i=1;i<=n;++i){
		if(dp[i]>ans){
			ans=dp[i];
			place=i;
		}
	}
	for(int i=n;i>place;--i) opt[++tot]=i;
	while(fa[place]!=0){
		int Next=fa[place];
		int mid=(Next+place)>>1;
		for(int i=mid;i>Next;--i) opt[++tot]=i;
		place=fa[place];
	}
	for(int i=1;i<place;++i) opt[++tot]=1;
	cout<<ans<<endl<<tot<<endl;
	for(int i=1;i<=tot;++i) cout<<opt[i]<<endl;
	}
	
	return 0;
}

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

int main (){
    int N, M;
    cin>>N>>M;
    vector<vector<int>> S(M, vector<int>(0, 0));
    for(int i=0; i<M; i++){
        int k;
        cin>>k;
        for(int j=0; j<k; j++){
            int l;
            cin>>l;
            S.at(i).push_back(l);
        }
    }
    vector<int> P(M);
                for(int i=0; i<M; i++){
                    cin>>P.at(i);
                }
    int Sum=0;
    int Max=pow(2, N);
    vector<int> C(N);
    for(int i=0; i<N; i++){
        C.at(i)=0;
    }

    for(int Checker=0; Checker<Max; Checker ++){
        bool Cheko=true;
        for(int j=0; j<M; j++){
            
            int Count=P.at(j);
            for(int m=0; m<S.at(j).size(); m++){
                if(C.at(S.at(j).at(m)-1)==1){
                    Count ++;
                }
            }
            if(Count%2>0){
                Cheko=false;
                break;
            }
        }
        if(Cheko){
            Sum ++;
        }
        C.at(0) ++;
        for(int j=1; j<N; j++){
            if(C.at(j-1)==2){
                C.at(j) ++;
            }
        }
        for(int j=0; j<N; j++){
            C.at(j)%=2;
        }
    }
    cout<<Sum<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#define db double
#define LL long long
#define inf 0x3f3f3f3f
using namespace std;
int gi()
{
    int res=0,s=1; char ch;
    for(ch=getchar();(ch<'0'||ch>'9')&&ch!='-';ch=getchar());
    if(ch=='-') s=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) res=res*10+ch-48;
    return res*s;
}

const int mo=1000000007,maxn=900000;
LL jc[1000005],ny[1000005],ans,ways[1000005];
int n,m,k;

LL qp(LL x,LL y) {
    LL res=1;
    for(;y;y>>=1,x=x*x%mo)
	if(y&1) res=res*x%mo;
    return res;
}
LL C(int x,int y) {return x>=y&&y>=0 ? 1ll*jc[x]*ny[y]%mo*ny[x-y]%mo : 0;}

int main()
{
    n=gi(),m=gi(),k=gi();
    for(int i=0;i<=maxn;++i) jc[i]=i?jc[i-1]*i%mo:1;
    for(int i=maxn;i>=0;--i) ny[i]=i==maxn?qp(jc[i],mo-2):ny[i+1]*(i+1)%mo;
    
    if(m>k) swap(m,k);   //m<=k
    for(int i=0;i<=m;++i) ways[i]=qp(2,i);
    for(int i=m+1;i<=k;++i) ways[i]=(2*ways[i-1]%mo-C(i-1,m)+mo)%mo;
    for(int i=k+1;i<=m+k;++i) ways[i]=(2*ways[i-1]%mo-C(i-1,m)-C(i-1,i-1-k)+mo+mo)%mo;
    
    for(int all=n;all<=n+m+k;++all) {
	ans+=C(all-1,n-1)*qp(3,n+m+k-all)%mo*ways[all-n]%mo;
	ans>=mo?ans-=mo:0;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 22912
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

signed main(){
	cout<<fixed<<setprecision(7);
	
	int N;
	
	cin>>N;
	
	cout<<N*800-(N/15)*200<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#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;

int main(){
	int N,A,B;
	cin>>N>>A>>B;
	cout<<min(A*N,B);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        var S = ReadLine();
        var T = ReadLine();

        var dp = new int[S.Length + 1, T.Length + 1];
        for (int i = 0; i < S.Length; i++)
        {
            for (int j = 0; j < T.Length; j++)
            {
                chmax(ref dp[i + 1, j + 1], dp[i, j] + (S[i] == T[j] ? 1 : 0));
                chmax(ref dp[i + 1, j + 1], dp[i + 1, j]);
                chmax(ref dp[i + 1, j + 1], dp[i, j + 1]);
            }
        }

        //for (int i = 0; i < S.Length + 1; i++)
        //{
        //    for (int j = 0; j < T.Length + 1; j++)
        //    {
        //        Write(dp[i, j] + " ");
        //    }
        //    WriteLine();
        //}
        //WriteLine();

        int now = dp[S.Length, T.Length];
        int I = S.Length;
        int J = T.Length;
        var SB = new StringBuilder();
        while (now > 0)
        {
            while (dp[--I, J] == now)
            {

            }
            I++;
            while (dp[I, --J] == now)
            {

            }
            J++;

            SB.Insert(0, T[J - 1]);
            I--;
            J--;
            now--;
        }
        WriteLine(SB);

    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 48096
while True:
    h,w = map(int,input().split())
    if h == w == 0:
        break
    for i in range(h):
        for j in range(w):
            if i == 0 or i == h-1 or j == 0 or j == w-1:
                print('#',end='')
            else:
                print('.',end='')
        print()
        
    print()


Measured memory_bytes: 7000
import java.util.Scanner;

/**
 * https://abc076.contest.atcoder.jp/tasks/abc076_c
 */
public class Main {

	public static void main(String[] args) throws Exception {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] t = new double[N];
		double[] v = new double[N];
		for(int i=0; i<N; i++) t[i] = sc.nextDouble();
		for(int i=0; i<N; i++) v[i] = sc.nextDouble();
		sc.close();
	
		v[N-1] = Math.min(v[N-1],t[N-1]);
		for(int i=N-2; i>=0; i--){
			v[i] = Math.min(v[i], v[i+1]+t[i]);
		}
		
		double ans = 0;
		double current = 0;
		for(int i=0; i<N; i++){
			double next = i==N-1 ? 0 : v[i]<v[i+1] ? v[i] : v[i+1];
			double maxV = 0;
			double previous = current;
			if(current+t[i]<=next){
				maxV = current+t[i];			
				current = maxV;
			}else{
				maxV = Math.min(v[i], (current+next+t[i])/2);
				ans -= (maxV-next)*(maxV-next)/2;
				current = next;
			}
			ans += maxV*t[i];
			ans -= (maxV-previous)*(maxV-previous)/2;
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 25300
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int NA = N/1000;
  int NB = N%1000/100;
  int NC = N%100/10;
  int ND =N%10;
  if ( NA == NB && NC == NB && NC==ND) {
    cout << "Yes" << endl;
  }
  else if (NA == NB && NB == NC) {
    cout << "Yes" << endl;
  }
  else if (NB ==NC && NC ==ND){
    cout<< "Yes" <<endl;
  }
  else {
    cout<< "No" <<endl;
  }
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val t = arrayOf(1, 3, 5, 7, 8, 10, 12)
    val a = sc.nextInt()
    val b = sc.nextInt()
    if (a == 2 || b == 2) {
        println("No")
    }
    else if (t.indexOf(a) != -1 && t.indexOf(b) != -1) {
        println("Yes")
    }
    else if (t.indexOf(a) == -1 && t.indexOf(b) == -1) {
        println("Yes")
    }
    else {
        println("No")
    }
}

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

using namespace std;
typedef pair<int, int> P;
const int MAXH = 301;
const int MAXW = 301;
const int MAXQ = 1e5 + 10;

int a[MAXH][MAXW];
P field[MAXH*MAXW];
bool visited[MAXH*MAXW];
vector<int> cost[MAXH*MAXW];
int l[MAXQ], r[MAXQ];

int h, w, d, q;
void solve() {
  for (int y=0;y<h;y++) {
    for (int x=0;x<w;x++) {
      field[a[y][x] - 1] = P(x, y);
    }
  }

  for (int i=0;i<=w*h;i++) {
    if (!visited[i]) {
      cost[i].reserve((w*h-i) / d);
      cost[i].push_back(0);
      for (int j=1;i + j * d<=w*h;j++) {
        visited[i + j * d] = true;
        P& p1 = field[i + (j-1) * d];
        P& p2 = field[i + j * d];
        cost[i].push_back(cost[i][j-1] + abs(p1.first - p2.first) + abs(p1.second - p2.second));
      }
    }
  }


  for (int i=0;i<q;i++) {
    l[i]--;r[i]--;
    int start = l[i] % d;
    cout << (cost[start][(r[i] - start) / d] - cost[start][(l[i] - start) / d]) << endl;
  }
}

int main() {
  cin >> h >> w >> d;
  for (int y=0;y<h;y++) {
    for (int x=0;x<w;x++) {
      cin >> a[y][x];
    }
  }
  cin >> q;
  for (int i=0;i<q;i++) {
    cin >> l[i] >> r[i];
  }
  solve();
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for (ll i = k; i <= n+1; ++i) {
        ans+=((n-i+1+n)*i/2%Mod+Mod-i*(i-1)/2%Mod+1)%Mod;
        //cout<<((n-i+1+n)*i/2%Mod+Mod-i*(i-1)/2%Mod)%Mod<<endl;
        ans%=Mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define mo 998244353
string str;
//map<int, int>::iterator itr; 
ull bin(ull a, ull n) {
    ull res = 1;
    while (n) {
        if (n & 1) res = 1LL * res * a % mo;
        a = 1LL * a * a % mo;
        n >>= 1;
    }
    return res;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;t=1;
    while(t--){
        int a,b,c,k;cin>>a>>b>>c>>k;
        while(k--){
            if(a>=b){
                b=b*2;
            }
            else{
                c=c*2;
            }
        }
        if(b>a&&c>b)
        cout<<"Yes";
        else
        cout<<"No";
        }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi n, q, su=0, tmp;
	vector<int> v, b, c, mp;

	cin>> n;
	v.resize(n);
	mp.resize(100010);

	rep(i, n){
		cin >> v[i];
		su+=v[i];
		mp[v[i]]++;
	}
	
	cin>> q;
	b.resize(q);
	c.resize(q);

	rep(i, q) {
		cin>> b[i] >> c[i];
	}

	rep(i, q){
		mp[c[i]]+=mp[b[i]];
		tmp=mp[b[i]]*(c[i]-b[i]);
		mp[b[i]]=0;
		su+=tmp;
		cout<< su <<endl;
	}
 
	return 0;
}

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

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

	if((n[0]==n[1]&&n[1]==n[2])||n[1]==n[2]&&n[2]==n[3]){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <utility>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>

using namespace std;
#define REP(i, n)  for(int i=0;i<(int)(n);++i)
#define FOR(i, b, n)  for(int i=b;i<(n);++i)
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define SS size()
#define ST first
#define ND second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
int n;
ll C;
vector<pll> su;

ll solve() {
   vl back(n+1); back[n] = 0;
   ll sum = 0;
   for(int i=n-1; i>=0; i--) {
       sum += su[i].ND;
       back[i] = max(back[i+1], sum - (C - su[i].ST));
   }
   sum = 0;
   ll ans = 0;
   for(int i=0; i<n; i++) {
       sum += su[i].ND;
       amax(ans, sum - su[i].ST);  //single pass
       amax(ans, sum - 2 * su[i].ST + back[i+1]); //right-back-left
   }
   return ans;
}


int main() {
//    ios::sync_with_stdio(0);
    cin >> n >> C;
    ll x, v;
    ll ans = 0;
    REP(i,n) {cin >> x >> v; su.push_back({x,v});}
    sort(ALL(su));
    ans = solve();
    REP(i,n) su[i].ST = C - su[i].ST;
    sort(ALL(su));
    amax(ans, solve());
    cout << ans << endl;
}






















Measured memory_bytes: 2544
IDENTIFICATION DIVISION.
      PROGRAM-ID. 158A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      01 S.
      	03 S1 PIC X(1).
      	03 S2 PIC X(1).
      	03 S3 PIC X(1).
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      MOVE INP TO S.
      
      EVALUATE TRUE
      WHEN ( S1 = S2 ) AND ( S2 = S3 )
      	DISPLAY "No"
      WHEN OTHER
      	DISPLAY "Yes"
      END-EVALUATE.
      
      STOP RUN.

Measured memory_bytes: 764
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

template<class In>
void print_array(In begin, In end) {
  cout << (*begin);
  begin++;
  for (; begin != end; begin++)
  {
    cout << " " << (*begin);
  }
  cout << endl;
}

ll gcd(ll a, ll b) {
  if (b % a == 0)
    return a;
  else
    return gcd(b % a, a);
}

int main()
{
  ll a, b;
  cin >> a >> b;
  cout << gcd(min(a, b), max(a, b)) << endl;

  return 0;
}



Measured memory_bytes: 3084
#include <iostream>
using namespace std;
int main(){
int n, arr[100005], ar[100005];
cin >> n;
for(int i=1; i<=n; i++){
cin >>arr[i];
}
for(int i=1; i<=n; i++){
ar[arr[i]]=i;
}
for(int i=1; i<=n; i++){
cout << ar[i];
if(i<n){
cout << " ";
}
else{
cout << endl;
}
}
return 0;
}

Measured memory_bytes: 1536
def include3?(x)
  if x % 10 == 3
    return true
  elsif x != 0
    return include3?(x / 10)
  else
    return false
  end
end
for i in 1..gets.to_i
  if i % 3 == 0 or include3?(i)
    print " " + i.to_s
  end
end
puts

Measured memory_bytes: 6092
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long long LL;
typedef double db;
const int oo=2139063143;
const int N=1010000;
const int P=1000000007;
const db eps=1e-7;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
    if (x< 0) putchar('-'),x=-x;
    if (x>=10) print(x/10);
    putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
template <typename T1,typename T2>
void chkmax (T1 &A,T2 B) { A=A>=B?A:B; }
template <typename T1,typename T2>
void chkmin (T1 &A,T2 B) { A=A<=B?A:B; }
int n,m,a[N];
int check (int p,bool op=0)
{
	int ans=0;
	for (int i=1,j=p; i<=j; i++,j--)
	{
		int g=a[i]+a[j];
		if (g>=m) return -1;
		chkmax (ans,a[i]+a[j]);
	}
	for (int i=p+1,j=n*2; i<=j; i++,j--)
	{
		int g=a[i]+a[j];
		if (g< m) return 1;
		chkmax (ans,a[i]+a[j]-m);
	}
	if (op) pr(ans);
	return 0;
}
int main ()
{
    // freopen (".in","r",stdin);
    // freopen (".out","w",stdout);
	sc(n),sc(m);
	for (int i=1; i<=n*2; i++)
		sc(a[i]);
	sort (a+1,a+n*2+1);
	int L=-1,R=n+1;
	while (L+1< R)
	{
		int mid=(L+R)>>1;
		if (check (mid<<1)<=0) R=mid;
		else L=mid;
	}
	check (R<<1,1);


    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

bool alpha1[26], alpha2[26];

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int max = -1;
  for(int i=0; i<N; i++){
    string S1 = S.substr(0, i);
    string S2 = S.substr(i, N);
    for(int j=0; j<26; j++)
      alpha1[j] = alpha2[j] = false;
    for(int j=0; j<i; j++)
      alpha1[int(S1[j]) - int('a')] = true;
    for(int j=0; j<N-i; j++)
      alpha2[int(S2[j]) - int('a')] = true;
    int tmp = 0;
    for(int j=0; j<26; j++)
      if(alpha1[j] && alpha2[j])
        tmp++;
    if(tmp > max)
      max = tmp;
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 256
void solve(){
}
void main(){
	string s = instr();
	writeln( s==s.dup.reverse.to!string?"Yes":"No" );
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;
alias instr = () => readln().chomp();
T inelm(T= int)(){ return to!(T)( readln().chomp() ); }
T[] inary(T = int)(){ return readln().chomp().split().to!(T[])(); }



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

using namespace std;

int P, Q, R;
string str;
int pos;

int formula() {
  pos ++;
  int f;
  if(str[pos] == '(') {
    f = formula(); pos ++;
    if(str[pos] == '+') {
      f = max(f, formula());
    }
    if(str[pos] == '*') {
      f = min(f, formula());
    }
    pos ++;
    return f;
  }
  
  if(str[pos] == '-') {
    return 2-formula();
  }
  
  if(isdigit(str[pos])) {
    return str[pos]-'0';
  }
  
  if(str[pos] == 'P') return P;
  if(str[pos] == 'Q') return Q;
  if(str[pos] == 'R') return R;
    
}

int main() {
  while(cin >> str && str != ".") {
    int cnt = 0;
    for(P=0; P<=2; P++)
      for(Q=0; Q<=2; Q++)
	for(R=0; R<=2; R++) {
	  pos = -1;
	  if(formula() == 2) cnt ++;
	}
    
    cout << cnt << endl;
  }
  return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<VI> r(n);
	rep(i ,n-1){
		int a, b; cin >>a >>b;
		r[a-1].push_back(b-1);
		r[b-1].push_back(a-1);
	}
	VI bf(n, -1), path;
	auto dfs =[&](auto dfs, int s) ->void{
		for(auto v: r[s]) if(bf[v] ==-1){
			bf[v] = s;
			dfs(dfs, v);
		}
	};
	bf[0]=-9; dfs(dfs, 0);
	int cr = n-1;
	while(cr!=-9){
		path.push_back(cr); cr = bf[cr];
	}
	reverse(all(path));
	
	VI ecl(n, -1); int pz = sz(path);
	rep(i, pz){
		ecl[path[i]] = (i < (pz+1)/2)? 0: 1;
	}
	
	auto dfs2 =[&](auto dfs2, int s, int cl) ->void{
		for(auto v: r[s]) if(ecl[v] ==-1){
			ecl[v] = cl;
			dfs2(dfs2, v, cl);
		}
	};
	rep(i, n) if(ecl[i]>=0){
		dfs2(dfs2, i, ecl[i]);
	}
	//for(auto x :ecl) cerr<<x<<" "; dbg("");
	int fsm = count(all(ecl), 0);
	puts((fsm * 2 > n)? "Fennec": "Snuke");
	return 0;
}


Measured memory_bytes: 9848
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
const int N = 1e5+10;
int main()
{
    _SAD()
    int n,k;
    string s,ss;
    cin>>n>>s>>k;
    //ss=s[k-1];
    for(int i=0;i<SZ(s);i++)
    {
        if(s[k-1]!=s[i])
        {
            s[i]='*';
        }
    }
    cout<<s<<nl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var t=new string[s[0]];
		var g=new int[s[0]];
		var r=new int[s[1]];
		int p=0;
		for(int i = 0;i<s[0];i++) {
			t[i]=sc.S;
			for(int j = 0;j<s[1];j++) {
				if(t[i][j]=='#'){g[i]++;p++;}
			}
		}
		for(int i = 0;i<s[1];i++) {
			for(int j = 0;j<s[0];j++) {
				if(t[j][i]=='#'){r[i]++;}
			}
		}
		int m=1<<s[0],o=1<<s[1],ans=0;
		for(int i = 0;i<m;i++) {
			int d=0;
			for(int j = 0;1<<j<=i;j++) {
				if(((1<<j)&i)!=0){d+=g[j];}
			}
			for(int k = 0;k<o;k++) {
				int c=0,x=0;
				for(int j = 0;1<<j<=k;j++) {
					if(((1<<j)&k)!=0){
						c+=r[j];
						for(int l = 0;1<<l<=i;l++) {
							if(((1<<l)&i)!=0){
								if(t[l][j]=='#'){x++;}
							}
						}
					}
				}
				if(p-d-c+x==s[2]){ans++;}
			}
		}
		Console.WriteLine("{0}",ans);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27532
n=int(input())
a=[int(x) for x in input().split()]
m=int(input())
s=[int(x) for x in input().split()]

def cal(a):
    x=0
    while True:
        a[x]+=1
        if a[x]==2:
            a[x]=0
            x+=1
        else:
            break
    return a


mk=[0]*(n+1)
sums=[]

while  True:

    mk=cal(mk)
    if mk[n]==1:
        break
    ist=0
    for i in range(n):
        if mk[i]==1:
            ist+=a[i]
    sums.append(ist)

yon=[]

for b in range(m):
    if s[b] in sums:
        yon.append(str("yes"))
    else:
        yon.append(str("no"))

for h in range(m):
    print(yon[h])



Measured memory_bytes: 43080
from sys import stdin
n = int(input())
book = [0]*(n+1)
for _ in stdin.readlines()  :
        if 0 not in book : break 
        a, v = map(int, _.split())
        book[a] = v+1
max_val = max(book)
print(book.index(max_val), max_val-1)

Measured memory_bytes: 7652
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s, r;
	int n,i;
	bool b;
	cin>>n;
	while(n--)
	{
		cin>>s;
		r = "NA";
		if(s.size() > 5 && (s.size()&1)==0 && s[0]=='>')
		{
			if(s[1]=='\'')
			{
				if(s[s.size()-1]=='~' && s[s.size()/2]=='#')
				{
					b=true;
					for(i=2;i<s.size()/2;++i)
						if(s[i]!= '=') b=false;
					for(i=s.size()/2+1;i<s.size()-1;++i)
						if(s[i]!= '=') b=false;
					if(b) r = 'A';
				}
			}
			else if(s[1]=='^')
			{
				if(s[s.size()-1]=='~' && s[s.size()-2]=='~')
				{
					b=true;
					for(i=2;i<s.size()-2;i+=2)
						if( !(s[i]=='Q' && s[i+1]=='=') )b=false;
					if(b) r='B';
				}
			}
		}
		cout << r << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  long long count=0;
  
  cin >> N;
  
  int L[N];
  
  for(int i=0;i<N;i++){
    cin >> L[i];
  }
 
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
     for(int k=j+1;k<N;k++){
       if(L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]){
         if(L[i]+L[j]>L[k] &&L[j]+L[k]>L[i] && L[k]+L[i]>L[j] ){
           count++;                 
         }
       }
     }
    }
  }
  
  cout << count << endl;
}
 

Measured memory_bytes: 3576
#include <stdio.h>
    int main(void){
        // Your code here!
        int n;
        int w[9<<14]={};
        int s[100000]={};
        
        scanf("%d",&n);
        int k;
        for(int i=0;i<n;i++){
            scanf("%d",&k);
            w[k]++;
        }
        int max=0;
        for(int i=0;i<1e5;i++){
            s[i]=w[i-1]+w[i]+w[i+1];
            if(s[i]>s[max]){
                max=i;
            }
        }
        printf("%d\n",s[max]);
        
        
    }

Measured memory_bytes: 2680
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;


 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);
  
 

ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll 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(ret);
  return (ret);
}

ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


void Solve(){
  ll n; 
    cin>>n;
  if(n%2==0){
    cout<<(n-1)/2<<endl;
  }
  else{
    cout<<n/2<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int w,n,a[31];

  int i,c1,c2,t;

  scanf("%d",&w);
  for(i=1;i<=w;i++){
    a[i]=i;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d,%d",&c1,&c2);
    t=a[c1];
    a[c1]=a[c2];
    a[c2]=t;
  }
  for(i=1;i<=w;i++){
    printf("%d\n",a[i]);
  }
  return 0;
}
    

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int h, w, K;
  cin>>h>>w>>K;
  vector<vector<int>> g(h, vector<int>(w));
  for(int i=0;i<h;i++) for(int j=0;j<w;j++) {
    char c;
    cin >> c;
    g[i][j] = c - '0';
  }
  int result = 100000;
  for(int i=0;i<pow(2,h-1);i++) {
    bitset<9> b(i);
    vector<int> border;
    for(int j=0;j<b.size();j++) {
      if(b.test(j)) border.emplace_back(j);
    }
    border.emplace_back(h-1);
    int ans = border.size() - 1;
    vector<vector<int>> white(border.size(), vector<int>(w));
    for(int bo=0;bo<border.size();bo++) {
      int prev;
      if(bo == 0) prev = 0;
      else prev = border[bo-1]+1;
      for(int j=0;j<w;j++) {
        int num = 0;
        for(int k=prev;k<border[bo]+1;k++) {
          if(g[k][j]) num++;
        }
        white[bo][j] = num;
      }
    }
    vector<int> prevv(border.size());
    vector<int> now(border.size());
    bool yes = true;
    for(int j=0;j<w;j++) {
      for(int k=0;k<border.size();k++) {
        if(white[k][j] > K) {
          yes = false;
          break;
        }
        now[k] += white[k][j];
        if(now[k] > K) {
          ans++;
          for(int l=0;l<border.size();l++) {
            now[l] -= prevv[l];
          }
        }
        if(k == border.size()-1) {
          prevv = now;
        }
      }
    }
    if(!yes) continue;
    if(ans < result) result = ans;
  }
  cout << result << endl;
}


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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N, A, B; cin >> N >> A >> B;

	vll healths (N);
	F0R(i, N) cin >> healths[i];

	ll lo = 0;
	ll hi = 2000000000;

	while (lo < hi) {
		ll mid = lo + (hi - lo) / 2;

		ll useBig = 0;
		F0R(i, N) {
			ll extra = max(0LL, healths[i] - B * mid);
			useBig += extra / (A - B) + (extra % (A - B) != 0);
		}
		if (useBig <= mid) {
			hi = mid;
		} else {
			lo = mid + 1;
		}
	}
	print(lo);
}

Measured memory_bytes: 1024
#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() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = a * c;
  ans = max(ans, a * d);
  ans = max(ans, b * c);
  ans = max(ans, b * d);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    String s =  sc.nextLine();
    char a = 'A';
    char b = 'Z';
    
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    
    for(int i = 0;i<s.length();++i){
           
      if(a!=(s.charAt(i))){
        count1 +=1;
      }
      if(a==(s.charAt(i))){
        break;
      }
    }
    
    
    
    for(int i = 0;i<s.length();++i){
           
      if((b==(s.charAt(i))) && (count2<=i)){    
        
          count2=i; 
        
      }
      
    }
    count2 +=1;

    int result = count2 - count1;
    System.out.println(result);

  }
}

Measured memory_bytes: 41812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0339
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = RInt();
            HashSet<int> hs = new HashSet<int>();
            for (int i = 0; i < n; i++)
            {
                int[] vs = RArInt().OrderBy(x => x).ToArray();
                int num = 0;
                for (int j = 0; j < vs.Length; j++)
                {
                    num += vs[j] << 10 * j;
                }
                hs.Add(num);
            }
            Console.WriteLine(n - hs.Count());
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 18628
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    x1,y1,x2,y2=map(int,input().split())
    x,y=x2-x1,y2-y1
    x3,y3=x2-y,y2+x
    x4,y4=x3-x,y3-y
    print(x3,y3,x4,y4)
resolve()

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

int main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	vector<int> v;
	v.push_back(a1);
	v.push_back(a2);
	v.push_back(a3);
	sort(v.begin(), v.end());
	cout << v[2] - v[0]<< endl;
	return 0;
}

Measured memory_bytes: 256
fun main(arr: Array<String>) {
    val (n,x) = readLine()!!.split(" ").map { it.toInt() }
    var a = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    a.add(x)
    a = a.distinct().sorted().toMutableList()
    a = (1..a.lastIndex).map { a[it] - a[it-1] }.toMutableList()
    println(a.reduce { acc, i -> getGCM(acc, i) })
}

fun getGCM(num1:Int, num2:Int):Int {
    if(num1 % num2 == 0) {
        return num2
    }
    return getGCM(num2, num1%num2)
}

Measured memory_bytes: 60060
#include <iostream>

using namespace std;

int main() {
  int N, M, Xmax, Ymin; cin >> N >> M >> Xmax >> Ymin;
  for(int i = 0; i < N; i++) {
    int num; cin >> num;
    if(num > Xmax) Xmax = num;
  }
  for(int i = 0; i < M; i++) {
    int num; cin >> num;
    if(num < Ymin) Ymin = num;
  }
  if(Ymin - Xmax > 0) cout << "No War" << endl;
  else cout << "War" << endl;
  return 0;
}

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 k = sc.nextInt();
        if(n % k == 0){
            System.out.println(0);
        }else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 22100
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstring>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erase(unique(all(v)),v.end());
#define pvec(v) rep(i,v.size()){ cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sizeof(m))

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
#define mod 1e9 + 7;
ll dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

ll gcd(ll x, ll y)
{
	ll r;
	while ((r = x % y) != 0)
	{
		x = y;
		y = r;
	}
	return y;
}
ll lcm(ll x, ll y)
{
	x /= gcd(x, y);
	y /= gcd(x, y);
	return (x * y);
}





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

	ll a = 0, b = 0, c = 0, d, e, ans = 0,j=0, n, ret = M, m, x = 0, y = 0;
	//bool x = false;
	string s,t;
	cin >> n;
	if (n == 25) cout << "Christmas" << endl;
	if (n == 24) cout << "Christmas Eve" << endl;
	if (n == 23) cout << "Christmas Eve Eve" << endl;
	if (n == 22) cout << "Christmas Eve Eve Eve" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n, s) for (int i = 0; i < n; i += s)
#define graph map<int, vector<int>>
#define field vector<vector<int>>
using namespace std;
int main()
{
    int d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	cin>>n;
    int a[n];

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

    int ans=*max_element(a,a+n)-*min_element(a,a+n);
    
	
    cout<<ans<<endl;

	return 0;
}


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

struct Knap{
    ll wt;
    ll val;
}G[110];

bool cmp(Knap &a , Knap &b){
    if(a.wt == b.wt)
        return a.val < b.val;
    return a.wt < b.wt;
}

void Knapsack(int n , int w){
    int i , j;
    ll k[n+3][w+3];
    for(i=0;i<=n;i++){
        for(j=0;j<=w;j++){
            if(i == 0 || j == 0)
                k[i][j] = 0;
            else if(G[i-1].wt <= j)
                k[i][j] = max(G[i-1].val + k[i-1][j-G[i-1].wt],k[i-1][j]);
            else
                k[i][j] = k[i-1][j];
        }
    }
    cout<<k[n][w]<<endl;
}

int main(){
    int i , j , n , w , v;
    cin>>n>>w;
    for(i=0;i<n;i++)
        scanf("%lld %lld",&G[i].wt ,&G[i].val);
    sort(G,G+n,cmp);//sorting val/weight in ascending order
    Knapsack(n,w);
}


Measured memory_bytes: 80256
// Ho-kago Tea Time

#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

inline int inv(int x) { assert(x); return fpm(x, MOD - 2); }

const int MAXN = (int) 3e3;

namespace MATH
{
	const int n = MAXN;

	int fac[n + 5], ifac[n + 5];

	inline void init()
	{
		fac[0] = 1;
		for(int i = 1; i <= n; ++i) fac[i] = (LL) fac[i - 1] * i % MOD;
		ifac[n] = inv(fac[n]);
		for(int i = n - 1; i >= 0; --i) ifac[i] = (LL) ifac[i + 1] * (i + 1) % MOD;
	}

	inline int C(int N, int M) { return N < 0 || M < 0 || N < M ? 0 : (LL) fac[N] * ifac[N - M] % MOD * ifac[M] % MOD; }
}
using MATH::C;

int n, m;

inline char safe_getchar()
{
	register char ch(getchar());
	while(!isdigit(ch)) ch = getchar();
	return ch;
}

int a[MAXN + 5], R[MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>();
	for(int i = 1; i <= n; ++i) a[i] = safe_getchar() - '0';
	for(int i = 1; i <= m; ++i)
	{
		int l = read<int>(), r = read<int>();
		chkmax(R[l], r);
	}
}

struct seg
{
	int l, r;

	seg() { }
	seg(int _l, int _r): l(_l), r(_r) { }
};

inline void solve()
{
	static seg s[MAXN + 5];
	int M = 0;

	for(int lst = 0, i = 1; i <= n; ++i) if(R[i] >= i && chkmax(lst, R[i])) s[++M] = seg(i, R[i]);
	s[M + 1] = seg(s[M].r + 1, s[M].r);

	static int c[MAXN + 5], l[MAXN + 5], t[MAXN + 5], f[MAXN + 5][MAXN + 5];

	for(int i = 1; i <= M; ++i)
	{
		c[i] = max(0, s[i - 1].r - s[i].l + 1);
		l[i] = min(s[i + 1].l, s[i].r + 1) - s[i].l;
		for(int j = max(s[i - 1].r + 1, s[i].l); j <= s[i].r; ++j) t[i] += a[j] == 0;
	}

	f[0][0] = 1;
	for(int i = 1; i <= M; ++i)
		for(int j = 0; j <= n; ++j)
		{
			f[i][j] = 0;
			for(int k = 0; k <= l[i]; ++k) if(j - t[i] + k >= 0 && j - t[i] + k <= c[i]) (f[i][j] += (LL) f[i - 1][j - t[i] + k] * C(l[i], k) % MOD) %= MOD;
		}
	printf("%d\n", f[M][0]);
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	MATH::init();
	input();
	solve();

	return 0;
}



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

int main() {
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  ll sum = 0;
  if (K <= A){
    sum = K;
    K = 0;
  } else {
    K = K - A;
    sum += A;
  }

  if (K <= B){
    K = 0;
  } else {
    K = K - B;
  }
  if (K <= C){
    sum -= K;
  } else {
    sum -= C;
  }
  cout << sum << endl;  
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  char c1,c2,c3;
  cin >> c1 >> c2 >> c3;
  if(c1==c3)cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
s = input()
count = []
num = 0
for i in range(len(s)):
    if s[i] == "A" or s[i] == "T" or s[i] == "C" or s[i] == "G":
        num += 1
    else:
        count.append(num)
        num = 0
count.append(num)
print(max(count))

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//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();}


int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n){
    cin >> a[i];
  }
  bool up,down;
  up = down = false;
  ll ans = 1;
  rep(i,n-1){
    if(up == false && down == false){
      if(a[i] - a[i+1] == 0)  continue;
      else if(a[i] - a[i+1] < 0) down = true;
      else if(a[i] - a[i+1] > 0) up = true;
    }else if(up){
      if(a[i] - a[i+1] < 0){
        up = false;
        ans ++;
      }
    }else if(down){
      if(a[i] - a[i+1] > 0){
        down = false;
        ans ++;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

#define ii pair<int,int> 
const int MAXN = 1e5 + 5;

int n;
int a[MAXN];
vector<int> pos, neg;
vector<ii> seq;
int ans;

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; ++i){
		scanf("%d", &a[i]);
	}
	sort(a, a+n);
	pos.push_back(a[n-1]);
	neg.push_back(a[0]);
	for(int i = 1; i < n-1; ++i){
		if(a[i] > 0)
			pos.push_back(a[i]);
		else
			neg.push_back(a[i]);
	}
	if(pos.size() == 1){
		int cur = pos[0];
		for(int i = 0; i < neg.size(); ++i){
			seq.push_back(ii(cur, neg[i]));
			cur = cur-neg[i];
		}
		ans = cur;
	}else{
		int cur = neg[0];
		for(int i = 1; i < pos.size(); ++i){
			seq.push_back(ii(cur, pos[i]));
			cur = cur-pos[i];
		}
		// Flip
		seq.push_back(ii(pos[0], cur));
		cur = pos[0]-cur;
		for(int i = 1; i < neg.size(); ++i){
			seq.push_back(ii(cur, neg[i]));
			cur = cur-neg[i];
		}
		ans = cur;
	}
	printf("%d\n", ans);
	for(ii i : seq){
		printf("%d %d\n", i.first, i.second);
	}
}

Measured memory_bytes: 3828