akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (A == 1)A = 14;
	if (B == 1)B = 14;
	if (A > B)printf("Alice");
	if (A < B)printf("Bob");
	if (A == B)printf("Draw");
	return 0;
}

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

#define int         long long
#define nn          3001
#define FAST        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int n;
int dp[nn][nn],a[nn];

int solve(int i,int j,int turn){
    if(i>j)
        return 0;

    if(dp[i][j] != -1)
        return dp[i][j];

    if(turn == 1)
        return dp[i][j] = max(a[i] + solve(i+1,j,0), a[j] + solve(i,j-1,0));
    
    else
        return dp[i][j] = min(solve(i+1,j,1), solve(i,j-1,1));
}

int32_t main() {
    FAST;
    memset(dp,-1,sizeof(dp));
    cin>>n;
    int sum = 0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum += a[i];
    }

    cout<<2*solve(1,n,1) - sum;
}


Measured memory_bytes: 70784
#pragma comment(linker, "/stack:640000000")

#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<stdio.h>
using namespace std;
#define ll long long int
#define scanl(a) scanf("%lld",&a)
#define scanii(a,b) scanf("%d%d",&a,&b)
#define scaniii(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scanll(a,b) scanf("%lld%lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scani(a) scanf("%d",&a)
#define clr(a) memset(a,0,sizeof(a))
#define clr_(a) memset(a,-1,sizeof(a))
#define pb(a) push_back(a)
#define pii pair<int,int>
#define sqr(a) a*a
#define eps 1e-9
#define inf INT_MAX
#define pi acos(-1.0)
#define ff first
#define ss second
#define INF (ll)1e18
#define m_p make_pair
#define vsort(v) sort(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define UNIQUE(X) sort(all(X)) X.resize( unique( all(X)) - X.begin() )
int fx[]={0,0,-1,1,-1,1,1,-1};
int fy[]={1,-1,0,0,1,1,-1,-1};
ll lcm(ll a,ll b){return (a/__gcd(a,b))*b;}
ll bigmod(ll a,ll p,ll mod){ll ans=1;while(p){if(p&1)ans=ans*a%mod;a=a*a%mod;p>>=1;}return ans;}
ll power(ll x,ll n){if(n==0)return 1;else if(n%2==0){ll y=power(x,n/2);return y*y;}else return x*power(x,n-1);}
struct point{double x,y;point(){}point(double xx,double yy){x=xx;y=yy;}};
inline double Distance(point  a,point b){return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
#ifdef shaft
     #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template < typename Arg1 >
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " is " << arg1 << std::endl;
    }
    template < typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names+1, ',');
        cerr.write(names, comma - names) << " is " << arg1 <<endl;
        __f(comma+1, args...);
    }
#else
    #define debug(...)
#endif
const int N=(int)1e6;
const ll mod=(ll)1e9+7;
int a[N],b[N],c[N];
ll arr[N];
int n;
int bin(int val){
    int low=0,high=n-1;
    int ans=n;
    while(low<=high){
        int mid=(low+high)/2;
        if(c[mid] > val){
            ans=mid;
            high=mid-1;
        }
        else low=mid+1;
      //  debug(c[mid],val,ans);
    }
    return ans;
}
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);
    #ifdef shaft
        freopen("in.txt","r",stdin);
        ///freopen("out.txt","w",stdout);
    #endif ///shaft

    scani(n);
    for(int i=0;i<n;i++)scani(a[i]);
    for(int i=0;i<n;i++)scani(b[i]);
    for(int i=0;i<n;i++)scani(c[i]);
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    for(int i=0;i<n;i++){
        int x=upper_bound(c,c+n,b[i])-c;
     //   debug(b[i],x);
        x=n-x;
        arr[i+1]=arr[i]+(ll)x;
    //    debug(arr[i+1]);
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        int x=upper_bound(b,b+n,a[i])-b;
        debug(x);
        ll temp=arr[n];
        temp-=arr[x];
        ans+=temp;
        debug(ans);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 9216
N,M=map(int,input().split())
A=[]
[A.append([int(i),1]) for i in input().split()]
for i in range(M):
	A.append(list(map(int,input().split()))[::-1])
A.sort(reverse=True)
cnt=0
ans=0
for a in A:
	if N<=(cnt+a[1]):
		ans+=(N-cnt)*a[0]
		break
	else:
		ans+=a[0]*a[1]
		cnt+=a[1]
print(ans)

Measured memory_bytes: 34260
import sys
readline = sys.stdin.readline
write = sys.stdout.write

M = 1000000
sq = int(M**.5)
pl = []
p = [1]*(M+1)
p[0] = p[1] = 0
for x in range(2, sq+1):
    if p[x]:
        for y in range(x*x, M+1, x):
            p[y] = 0
        pl.append(x)
for x in range(sq+1, M+1):
    if p[x]:
        pl.append(x)

def solve():
    N = int(readline())
    if N == 0:
        return False
    ans = 0
    N2 = N//2
    for x in pl:
        if N2 < x:
            break
        if p[N-x]:
            ans += 1
    write("%d\n" % ans)
    return True
while solve():
    ...


Measured memory_bytes: 16616
#include "bits/stdc++.h"
using namespace std;
typedef uint64_t ulong;
typedef int64_t slong;
typedef uint32_t uint;

int main() {
  //freopen("../output.txt", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int a, b, c, x, cnt = 0;
    cin >> a >> b >> c >> x;
    for (int i = 0; i <= a; i += 1) {
        for (int j = 0; j <= b; j+= 1) {
            for (int k = 0; k <= c; k+= 1) {
                if (i * 500 + j * 100 + k * 50 == x) ++cnt;
            }
        }
    }
    cout << cnt << '\n';
    return 0;
}


Measured memory_bytes: 256
N=int(input())
q=[list(map(int,input().split())) for _ in range(N)]
for i in range(101):
    for j in range(101):
        F=1
        r=[]
        for k in range(101):
            x,y,h=q[k]
            if h > 0:
              break
            r.append([x,y])
        s=h+abs(x-i)+abs(y-j)
        for x,y,h in q[1:]:
            if h==0:
                r.append([x,y])
                continue
            y=h+abs(x-i)+abs(y-j)
            if s!=y:
              F=0
              break
        if r:
          for x,y in r:
            if s-abs(x-i)-abs(y-j) > 0:
              F=0
              break
        if F==1:
          print(i,j,s)
          exit()

Measured memory_bytes: 3064
package main

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

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Traveling Salesman around Lake
	var K, N int
	fmt.Scanf("%d %d", &K, &N)

	sc.Split(bufio.ScanWords)
	var max int = 0
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt()
	}

	for i := 0; i < N-1; i++ {
		if max < A[i+1]-A[i] {
			max = A[i+1] - A[i]
		}
	}
	if max < (K-A[N-1])+A[0] {
		max = (K - A[N-1]) + A[0]
	}

	fmt.Println(K - max)
}


Measured memory_bytes: 5024
#include <iostream>
using namespace std;
int main(void){
    int a, b, c, d, n, count;
    while(cin >> n){
        count = 0;
        for(a=0; a<=9; a++){
            for(b=0; b<=9; b++){
                for(c=0; c<=9; c++){
                    for(d=0; d<=9; d++){
                        if(a+b+c+d == n){
                            count++;
                        }
                    }
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}



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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    vvi c(3,vi(3));
    rep(i,3){
        rep(j,3){
            cin>>c[i][j];
        }
    }
    bool a=true;
    rep(i,2){
        rep(j,2){
            if(c[i+1][j]-c[i][j]!=c[i+1][j+1]-c[i][j+1])a=false;
        }
    }
    if(a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
// Confessions of a Dangerous Mind

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 2e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 3e-16;

/*
	Keep moving forward. Take the Leap of Faith
*/

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
    long long n, m; cin >> n >> m;
    
    n--, m--;
    
    cout << m / n + (m % n != 0);
    
	return 0;
}

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

public class Main {

  private static PrintWriter out;

  public static void main(String[] args) {
    Main main = new Main();
    Runtime.getRuntime().addShutdownHook(new Thread(() -> out.close()));
    try {
      main.run(args);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }

  private void run(String[] arguments) throws Exception {
    MyScanner sc = new MyScanner();
    out = new PrintWriter(new BufferedOutputStream(System.out));

    int N = sc.nextInt();

    N = N % 10;
    String ans = "";
    if (N==3){
      ans = "bon";
    }else if (N==0||N==1||N==6||N==8){
      ans = "pon";
    }else {
      ans = "hon";
    }
    out.println(ans);
    out.close();
  }

  /*          
   * Form: http://codeforces.com/blog/entry/7018
   */
  private class MyScanner {
    BufferedReader br;
    StringTokenizer st;

    MyScanner() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() {
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }
  }
}


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

#define sq(x) ((x)*(x))

string color_name[8] = {
	"black",
	"blue",
	"lime",
	"aqua",
	"red",
	"fuchsia",
	"yellow",
	"white"
};

int color_rgb[8][3] = {
	{ 0x00, 0x00, 0x00 },
	{ 0x00, 0x00, 0xff },
	{ 0x00, 0xff, 0x00 },
	{ 0x00, 0xff, 0xff },
	{ 0xff, 0x00, 0x00 },
	{ 0xff, 0x00, 0xff },
	{ 0xff, 0xff, 0x00 },
	{ 0xff, 0xff, 0xff },
};

int main( void )
{
	string input;
	while ( 1 )
	{
		cin >> input;
		if ( input == "0" ) break;
		int r, g, b;
		sscanf( input.c_str(), "#%2x%2x%2x", &r, &g, &b );

		int min_value = 1 << 28, min_no = 0;
		for ( int i = 0; i < 8; i++ )
		{
			int d = sq(r-color_rgb[i][0]) + sq( g-color_rgb[i][1] ) + sq(b-color_rgb[i][2]);
			if ( d < min_value )
			{
				min_value = d;
				min_no = i;
			}
		}

		cout << color_name[min_no] << endl;
	}
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  if(s=="AAA"||s=="BBB") cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
typedef long long ll;
using namespace std;

int main(){
    int A, B, T;
    cin >> A >> B >> T;
    int size = min(A,B);
    vector<int> d;
    int i = 1;
    while(i <= min(A,B)){
        if(A % i == 0 && B % i == 0){
            d.push_back(i);
        
        }
        i++;
    }
    srt(d);
    rev(d);
    cout << d[T - 1] << endl;
    return 0;
}

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

int N;

typedef long long ll;

ll T = 0,AO = 0,ans=0;

struct Data {
  ll  A[100000];
  ll  B[100000];
  ll  C[100000];
};

int main() {
  cin >> N;
  Data data;
  for ( int i = 0; i < 100000; i++ ) data.C[i] = 0;
  for ( int i = 0; i < N; i++ ) {
    cin >> data.A[i] >> data.B[i];
    data.C[i] = data.A[i] + data.B[i];
  }

  sort(data.C,data.C+N);

  for ( int i = 0; i < N; i++ ) ans -= data.B[i];
  
  for ( int i = N-1; i >= 0; i-=2 ) {
    ans += data.C[i];
  }

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


Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define max(a,b) (a<b?b:a)
#define abs(x) (x<0?(-x):x)
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define RF(i,L,R) for (int i = L; i > R; i--)
#define RFE(i,L,R) for (int i = L; i >= R; i--)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define ll long long
#define INF 2000000000
#define nINF -2000000000
#define MOD 1e9+7
#define PI 3.1415926535897932384626
char in[15];
int toInt(int op){
	int ans=in[op]*100+in[op+1]*10+in[op+2];
	return ans;
}
int main(){
	while(~scanf("%s",in)){
		int l=strlen(in),ans=INF;
		F(i,0,l) in[i]-='0';
		F(i,0,l-2){
			int num=toInt(i);
			num-=753;
			if(abs(num)<ans) ans=abs(num);
		}
		printf("%d\n",ans);
	}
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int a[509][509];
int s[509][509];


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int n, m, q; cin >> n >> m >> q;
    REP(i, m) {
        int l, r; cin >> l >> r;
        a[l][r]++;
    }
    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= n; ++j) {
            s[i][j] = a[i][j] + s[i][j - 1];
        } // スタートがiでゴールがj
    }
    REP(i, q) {
        int ans = 0;
        int l, r;
        cin >> l >> r;
        for(int j = l; j <= r; ++j) {
            ans += s[j][r] - s[j][l - 1];
        }
       cout << ans << endl;
    }

    

    return 0;
}

Measured memory_bytes: 2944
MOD=10**9+7
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
r1,c1,r2,c2=map(int,input().split())
l=[1]*2000022
for i in range(1,2000022):
  l[i]=l[i-1]*ModInt(i)
def comb(a,b):
  c,d=int(a),int(b)
  if a==b or b==0 or a==0:return 1
  return l[c]/l[d]/l[c-d]
ans=((ModInt(r2)+2)*comb(c2+r2+2,r2+2)-ModInt(c2)-1)/(ModInt(c2)+1)-((ModInt(r1)+1)*comb(c2+r1+1,r1+1)-ModInt(c2)-1)/(ModInt(c2)+1)-((ModInt(r2)+2)*comb(c1+r2+1,r2+2)-ModInt(c1)-2)/ModInt(c1)+((ModInt(r1)+1)*comb(c1+r1,r1+1)-ModInt(c1)-2)/ModInt(c1)
print(ans)

Measured memory_bytes: 216492
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
const int mod=1e9+7;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main(){
    fast;
    string s1,s2;
    cin>>s1;
    cin>>s2;
    bool m=0;
    if(s2.length()-1!=s1.length()) cout<<"No";
    else{
        for(int i=0;i<s1.length();i++){
            if(s1[i]!=s2[i]){
                m=1;
                break;
            }
        }
        if(m) cout<<"No\n";
        else cout<<"Yes\n";
    }
}

Measured memory_bytes: 3640
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n;
  std::vector<ll> v(n),w(n);
  rep(i,n) {
    cin>>v[i];
    w[i] = v[i];
    if(i>=1){
      w[i] = MAX(w[i],w[i-1]);
    }
  }
  ll ans = 0;
  rep(i,n){
    if(v[i]>=w[i]) ans++;
  }

  cout<<ans<<endl;

}

int main(){
  solve();
  return 0;
}


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

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

  map<char, int> aMap;

  int mx = 0;
  for (int i = 0; i < n; i++) {
    if (aMap[s[i]] == 0) { aMap[s[i]]++; }
    map<char, int> bMap;
    int cnt = 0;
    if (i != n - 1) {
      for (int j = i + 1; j < n; j++) {
        if (aMap[s[j]] == 1 && bMap[s[j]] == 0) {
          cnt++;
          bMap[s[j]]++;
        }
      }
    }
    mx = max(mx, cnt);
  }
  cout << mx << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
  var N, ans int
  var S string
  fmt.Scan(&N, &S)
  for i := 0; i < N-1; i++{
    if S[i] != S[i+1] {
      ans++
    }
  }
  fmt.Println(ans+1)
}


Measured memory_bytes: 1280
import java.util.Scanner;
 
class Main {  
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double x1 = in.nextDouble();
        double x2 = in.nextDouble();
        double y1 = in.nextDouble();
        double y2 = in.nextDouble();
 
        double distance = Math.sqrt((x1 - y1)*(x1 - y1) + (x2 - y2)*(x2 - y2));
     
        System.out.printf("%5.8f", distance);
     
    }
}

Measured memory_bytes: 19140
#include <bits/stdc++.h>
#define INF (1LL<<50)
#define s second
#define f first
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
typedef pair<ll,P> PP;
ll G[200][200][2];
int n,m,r,z[1000];

void WF(){
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	G[i][j][0]=min(G[i][j][0],G[i][k][0]+G[k][j][0]);
	G[i][j][1]=min(G[i][j][1],G[i][k][1]+G[k][j][1]);
      }
}


ll dijkstra(){
  vector<vector<ll> > D(n,vector<ll>(r,INF));
  vector<vector<int> > used(n,vector<int>(r,0));
  priority_queue<PP,vector<PP>,greater<PP> > Q;
  Q.push(PP(0,P(z[0],0)));
  D[z[0]][0] = 0;

  while(!Q.empty()){
    PP t=Q.top();Q.pop();
    ll cost=t.f,ship=t.s.f,idx=t.s.s,pos=z[idx];
    if(idx==r-1)return cost;
    if(used[ship][idx]++) continue;
    
    int npos=z[idx+1];
    ll ncost=cost+G[pos][npos][0];
    if(D[ship][idx+1]>ncost)Q.push(PP(ncost,P(ship,idx+1))),D[ship][idx+1]=ncost;

    for(int i=0;i<n;i++){
	ncost=cost+G[pos][ship][0]+G[ship][i][1]+G[i][npos][0];
	if(D[i][idx+1]>ncost)Q.push(PP(ncost,P(i,idx+1))),D[i][idx+1]=ncost;
      }
  }
  assert(0);
} 

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<n;i++) 
      for(int j=0;j<n;j++) G[i][j][0]=G[i][j][1]=INF*(i!=j);
    
    for(int i=0,x,y,c,idx;i<m;i++){
      char ch;
      cin>>x>>y>>c>>ch;x--,y--;
      idx=(ch=='S');
      G[x][y][idx]=G[y][x][idx]=min(G[x][y][idx],(ll)c);
    }
    cin>>r;
    for(int i=0;i<r;i++)cin>>z[i],z[i]--;
    WF();
    cout <<dijkstra()<<endl;
  }
  return 0;
}

Measured memory_bytes: 6100
import sys;raw_input = sys.stdin.readline
N = int(raw_input())
P = [None]*N
for i in xrange(N):
    P[i] = int(raw_input())-1
def solve(C):
    N = len(C)
    I = [None]*N
    for i in xrange(N):
        I[C[i]] = i
    D = [1]*N 
    for i in xrange(1, N):
        D[i] = (D[i-1] + 1) if I[i] > I[i-1] else 1
    return N - max(D)
print solve(P)

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if(b / a >= c) {
        cout << c << endl;
    } else {
        cout << b / a << endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}

template <class T>
class SegTree {
    int n;// 葉の数
    vector<T> data;// データを格納するvector
    T def; // 初期値かつ単位元
    function<T(T, T)> operation; // 区間クエリで使う処理
    function<T(T, T)> update;// 点更新で使う処理

    T find(int a, int b) {
        ll val_left = def, val_right = def;
        for (a += (n - 1), b += (n - 1); a < b; a >>= 1, b >>= 1)
        {
            if ((a & 1) == 0){
                val_left = operation(val_left, data[a]);
            }
            if ((b & 1) == 0){
                val_right = operation(val_right, data[--b]);
            }
        }
        return operation(val_left, val_right);
    }
    public:
    // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
    // _update:更新関数
    SegTree(size_t _n, T _def, function<T(T, T)> _operation,
        function<T(T, T)> _update=[](T a,T b){return b;})
        : def(_def), operation(_operation), update(_update) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }
    void set(int i, T x) { data[i + n - 1] = x; }
    void build() {
        for (int k=n-2;k>=0;k--) data[k] = operation(data[2*k+1],data[2*k+2]);
    }
    // 場所i(0-indexed)の値をxで更新
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    // [a, b)の区間クエリを実行
    T query(int a, int b) {
        //return _query(a, b, 0, 0, n);
        return find(a,b);
    }

    // 添字でアクセス
    T operator[](int i) {
        return data[i + n - 1];
    }
};

int main(){
    ll n,q;cin >> n >>q;
    SegTree<ll> st(n,0,[](ll a,ll b){return a+b;},[](ll a,ll b){return a+b;});
    rep(i,n){
        ll a;cin >> a;st.set(i,a);
    }
    st.build();
    while(q--){
        ll t,p,x;cin >> t >> p >> x;
        if(t)cout << st.query(p,x) <<endl;
        else st.change(p,x);
    }
}

Measured memory_bytes: 12512
def main():
    import sys
    input = sys.stdin.readline
    
    n,k = map(int,input().split())
    a = list(map(int,input().split()))
    mod = 10**9+7
    
    fact = [1]
    fact_inv = [1]
    for i in range(10**5+5):
        fact.append(fact[-1]*(i+1)%mod)
        fact_inv.append(pow(fact[-1],mod-2,mod))
        
    def mod_comb_k(n,k,mod):
        return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod
    
    a.sort()
    
    res = 0
    for i in range(n-k+1):
        res = (res + (a[n-1-i]- a[i])*mod_comb_k(n-i-1,k-1,mod))%mod

    print(res)
if __name__ == '__main__':
    main()


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

int snuke[100];
int main() {
  int n,k,d,a;
  cin>>n>>k;
  for (int i = 0; i < k; ++i) {
    cin>>d;
    for (int j = 0; j < d; ++j) {
      cin>>a;
      snuke[--a]++;
    }
  }
  int cnt=0;
  for (int i = 0; i < n; ++i) if(!snuke[i])cnt++;
  cout<<cnt<<endl;
}


Measured memory_bytes: 3636
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    s=input()
    t=input()
    f=0
    if s==t[::-1]:
        f=1
    if f==1:
        print("YES")
    else:
        print("NO")

main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#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--)
#define mp make_pair
#define fi first
#define sc second
char a[200],b[200];
int main(){
	cin >> a >> b;

	if(strlen(a) != strlen(b)) {
		if(strlen(a) > strlen(b)) {
			cout << "GREATER" << endl;
		}
		else {
			cout << "LESS" << endl;
		}
	}else{
		bool f = true;

		for(int i = 0;i < strlen(a);i++) {
			if(a[i] > b[i]) {
				cout << "GREATER" << endl;
				f = false;
				break;
			}else if(a[i] < b[i]) {
				cout << "LESS" << endl;
				f = false;
				break;
			}
		}
		if(f) {
			cout << "EQUAL" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  bool flag = 0;
  rep(i, n) {
    char c; cin >> c;
    if (c == 'Y') {
      flag = 1;
      break;
    }
  }
  if (flag) cout << "Four" << endl;
  else cout << "Three" << endl;
}

Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(){
    int N, M, C, sum, count = 0;
    int A[20][20];
    int B[20];
    cin >> N >> M >> C;
    for(int i = 0; i < M; i++){
        cin >> B[i];
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < M; j++){
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        sum = C;
        for(int j = 0; j < M; j++){
            sum += A[i][j] * B[j];
        }
        if(sum > 0) count++;
    }
    cout << count << endl;
    return 0;
}

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


main(){
	int i,n,sum,mmin,mmax,t;
	while(cin>>n,n){
		sum=0;mmin=1000;mmax=0;
		for(i=0;i<n;i++){
			cin >> t;
			sum+=t;
			mmin = min(mmin,t);
			mmax = max(mmax,t);
		}
		cout << (sum-mmin-mmax)/(n-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define show(x) cout<< #x << " = " << x << endl
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=100010;

int N,C;
int d[33][33];
int c[505][505];

int main(){
	cin>>N>>C;
	REP(i,C)REP(j,C)cin>>d[i][j];
	REP(i,N)REP(j,N){
		cin>>c[i][j];
		c[i][j]--;
	}

	vector<int> g[3];
	REP(i,N){
		REP(j,N){
			if((i+j)%3==0)g[0].pb(c[i][j]);
			else if((i+j)%3==1)g[1].pb(c[i][j]);
			else if((i+j)%3==2)g[2].pb(c[i][j]);
		}
	}
	int sum[3][C];
	REP(i,3)REP(j,C)sum[i][j]=0;
	REP(i,3){
		REP(j,C){
			sum[i][j]=0;
			REP(k,g[i].size()){
				sum[i][j]+=d[g[i][k]][j];
			}
		}
	}

	int ans=INF;
	REP(i,C){
		REP(j,C){
			REP(k,C){
				if(i==j || j==k || k==i)continue;
				ans=min(ans,sum[0][i]+sum[1][j]+sum[2][k]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n;
long long d[MAX][MAX];

void floyd(){
	for(int k = 0; k < n; k++){
		for(int i = 0; i < n; i++){
			if(d[i][k] == INFTY) continue;
			for(int j = 0; j < n; j++){
				if(d[k][j] == INFTY) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main(){
	int e, u, v, c;
	cin >> n >> e;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			d[i][j] = ((i == j) ? 0 : INFTY);
		}
	}

	for(int i = 0; i < e; i++){
		cin >> u >> v >> c;
		d[u][v] = c;
	}

	floyd();

	bool negative = false;
	for(int i = 0; i < n; i++) if(d[i][i] < 0) negative = true;

	if(negative){
		cout << "NEGATIVE CYCLE" << endl;
	}else{
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				if(j)cout << " ";
				if(d[i][j] == INFTY) cout << "INF";
				else cout << d[i][j];
			}
			cout << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3152
n=int(input())

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

t=1

for i in range(n):
    if a[i]%2==0 and a[i]%3==0:
        t=1
    elif a[i]%2==0 and a[i]%5==0:
        t=1
    elif a[i]%2==1:
        t=1
    else:
        t=0
        break 

if t==1:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 9188
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i = 0; i < n; i++){
            int a = sc.nextInt();
            if(map.containsKey(a)){
                map.put(a,map.get(a)+1);
            }else{
                map.put(a,1);
            }
        }
        if(map.size() >= 4){
            System.out.println("No");
        }else if(map.size() == 3){
            int xor = 0;
            for(Map.Entry<Integer,Integer> e : map.entrySet()){
                int k = e.getKey();
                int v = e.getValue();
                if(n % 3 == 0 && v == n / 3){
                    xor = xor^k;
                }else{
                    System.out.println("No");
                    return;
                }
            }
            System.out.println(xor == 0 ? "Yes" : "No");
        }else if(map.size() == 2){
            System.out.println(map.containsKey(0) && n % 3 == 0 && map.get(0) == n/3 ? "Yes" : "No");
        }else if(map.size() == 1){
            System.out.println(map.containsKey(0) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 60808
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    if (n%2) {
        cout << "No" << E;
    }
    else {
        bool ok = true;
        for (int i = 0; i < n/2; i++) {
            if (s[i] != s[i + n/2]) {
                ok = false;
                break;
            }
        }
        if (ok) cout << "Yes" << E;
        else cout << "No" << E;
    }
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define MM 1000000000
#define MOD MM+7
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T lcm(T x,T y){
    return x*y/GCD(x,y);
}
long long Pow(long long base,long long x){
    if (x == 0) return 1;
    if (x%2 == 1) return (base*Pow(base,x-1))%MOD;
    long long y = Pow(base, x/2);
    return y*y%MOD;
}

int main(){
    double x1,x2,y1,y2; cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(10) << (double)sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2)) << endl;
}
  




Measured memory_bytes: 3280
/*
* Author : Omkar Deshmukh
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define all(v) v.begin(), v.end()
#define intvect vector<int>
#define pii pair<int, int>
#define mii map<int, int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define Fo(i, k, n) for (int i = k; i < n; i++)
#define boolv vector<bool>
#define ld long double
#define deb(x) cout << #x << " " << x << endl;
#define pb push_back
#define pob pop_back
#define F first
#define S second
#define ull unsigned long long

bool flag = 0;
const ll mod = 1e9 + 7;
const ll N = (ll)5e5 + 4;
bool ans = 0;
// template <typename... T>
// void read(T &... args)
// {
//     ((cin >> args), ...);
// }

// template <typename... T>
// void write(T &&... args) //rvalue references
// {
//     ((cout << args << endl), ...);
//     ans = 1;
// }

void vjudge()
{
#ifndef ONLINE_JUDGE
    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void solve()
{
    int a[5];
    fo(i, 5) cin >> a[i];
    fo(i, 5)
    {
        if (a[i] == 0)
        {
            cout << i + 1;
            return;
        }
    }
}

int main()
{
    vjudge();
    int t = 1;
    // cin >> t;
    while (t--)
        solve();
}


Measured memory_bytes: 3608
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll mod=1e9+7;

ll dp[10010][2][105];

int main()
{
    string k;
    cin >> k;
    ll d;
    cin >> d;
    ll n=k.length();
    dp[0][0][0]=1;
    for(ll i=1;i<=n;i++){
        ll x=(ll)(k[i-1]-'0');
        for(ll j=0;j<=9;j++){
            for(ll p=0;p<d;p++){
                if(j==x){
                    dp[i][0][(p+j)%d]+=dp[i-1][0][p];
                    dp[i][0][(p+j)%d]%=mod;
                }
                if(j<x){
                    dp[i][1][(p+j)%d]+=(dp[i-1][1][p]+dp[i-1][0][p])%mod;
                    dp[i][1][(p+j)%d]%=mod;
                }
                else{
                    dp[i][1][(p+j)%d]+=dp[i-1][1][p];
                    dp[i][1][(p+j)%d]%=mod;
                }
            }
        }
    }
    ll ans=(dp[n][0][0]+dp[n][1][0]+mod-1)%mod;
    cout <<  ans << endl;
    return 0;
} 

Measured memory_bytes: 16640
/* Author: Newbie Abhishek Pandey */
                                       
#include<bits/stdc++.h>
#define Abhi_921 ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ld long double
#define fi(i,j,n) for(int i=j;i<n;i++)
#define fd(i,j,n) for(int i=j;i>n;i--)
#define print(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define inp(a,n) for(int i=0;i<n;i++) cin>>a[i]
#define printe(v) for(auto &i:v){cout<<i<<' ';}cout<<endl;
#define deb(n1) cout<<n1<<endl;
#define pb push_back
#define eb emplace_back
#define vi vector<ll>
#define vll vector<pair<ll,ll>>
#define umap unordered_map<ll,ll>
using namespace std;
const long long mod=1e9+7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
Abhi_921;
int t;
t=1;
while(t--){
ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans1=max(a,b)*max(c,d);
ll ans2=max(a,b)*min(c,d);
ll ans3=min(a,b)*max(c,d);
ll ans4=min(a,b)*min(c,d);
ll ans=max(max(ans1,ans2),max(ans3,ans4));
cout<<ans<<endl;
}
return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    string s;
    cin >> n >> s;
    int count = 1;
    for(int i = 0; i < n-1; i++){
        if(s.at(i) != s.at(i+1)){
            count += 1;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

ll dp[110000][20];

int main(){
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    ll temp=1;
    dp[0][0]=1;
    for(int i=0;i<(int)s.size();i++,temp*=10,temp%=13){
        for(int j=0;j<13;j++){
            if(s[i]=='?'){
                for(int k=0;k<10;k++){
                    dp[i+1][(j+k*temp)%13]+=dp[i][j];
                    dp[i+1][(j+k*temp)%13]%=MOD;
                }
            }else{
                dp[i+1][(j+(s[i]-'0')*temp)%13]+=dp[i][j];
                dp[i+1][(j+(s[i]-'0')*temp)%13]%=MOD;
            } 
        }
    }
    cout<<dp[s.size()][5]<<endl;

}


Measured memory_bytes: 16896
n=int(input())
s=input()
L=[]
done=False

for c in s:
    if c=="o":
        L.append(0)
    else:
        L.append(1)

ans="00"
for i in range(3,n+1):
    ans+=str((int(ans[i-3])+int(ans[i-2])+L[i-2])%2)

#print(ans)
if int(ans[0])==(int(ans[-1])+int(ans[-2])+L[-1])%2 and int(ans[1])==(int(ans[0])+int(ans[-1])+L[0])%2:
    pass

else:    
    ans="01"
    for i in range(3,n+1):
        ans+=str((int(ans[i-3])+int(ans[i-2])+L[i-2])%2)
    
    #print(ans)
    if int(ans[0])==(int(ans[-1])+int(ans[-2])+L[-1])%2 and int(ans[1])==(int(ans[0])+int(ans[-1])+L[0])%2:
        pass
    else:    
        ans="10"
        for i in range(3,n+1):
            ans+=str((int(ans[i-3])+int(ans[i-2])+L[i-2])%2)
        
        #print(ans)
        if int(ans[0])==(int(ans[-1])+int(ans[-2])+L[-1])%2 and int(ans[1])==(int(ans[0])+int(ans[-1])+L[0])%2:
            pass
        else:    
            ans="11"
            for i in range(3,n+1):
                ans+=str((int(ans[i-3])+int(ans[i-2])+L[i-2])%2)
            
            #print(ans)
            pass
            if int(ans[0])==(int(ans[-1])+int(ans[-2])+L[-1])%2 and int(ans[1])==(int(ans[0])+int(ans[-1])+L[0])%2:
                #print("!")
                pass
            else:
                print(-1)
                done=True

if not done:
    pri=""
    for c in ans:
        if c =="0":
            pri+="S"
        else:
            pri+="W"
    print(pri)
        

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)
int main(){
    int a,p; cin>>a>>p;
    cout<<(3*a+p)/2<<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();
		long arr[] = new long[N];
		for (int i = 0; i < arr.length; i++) {
			arr[i] = sc.nextLong();
		}
		Arrays.sort(arr);
		long atk = 0;
		for (int i = 0; i < arr.length-K; i++) {
			atk += arr[i];
		}
		System.out.println(atk);
      	sc.close();
    }
		
		
}


Measured memory_bytes: 88676
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
int ask(ll v) {
	string S;
	cout<<"? "<<v<<endl;
	cin>>S;
	return S[0]=='Y';
}
 
void ans(ll v) {
	cout<<"! "<<v<<endl;
	exit(0);
}
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	ll p10=10000000000LL;
	for(i=10;i>=1;i--) {
		if(ask(p10)==1) break;
		p10/=10;
	}
	
	if(i==10) {
		p10=10000000000LL;;
		for(i=10;i>=1;i--) {
			if(ask(p10-1)==0) ans(p10);
			p10/=10;
		}
	}
	if(i==0) {
		for(i=10;i<=90;i+=10) {
			if(ask(i)==1) ans(i/10);
		}
	}
	ll ret=0,cm=0;
	for(;p10>=1;p10/=10) {
		int cur=-1;
		int dd[4]={8,4,2,1};
		FOR(j,4) if(cur+dd[j]<10) {
			ll tmp=ret+(cur+dd[j])*p10;
			ll tmp2=cm*10+(cur+dd[j]);
			if(ask(tmp2*1000000000LL)==0) cur+=dd[j];
		}
		cm=cm*10+cur;
		ret+=p10*cur;
	}
	
	
	ans(ret+1);
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}

Measured memory_bytes: 596
H, W, K = map(int, input().split())
S = [input() for _ in range(H)]

group = [[0 for _ in range(W)] for _ in range(H)]
group_num = 1

for y in range(H):
    for x in range(W):
        if S[y][x] == ".":
            continue
        group[y][x] = group_num
        for r in [(x-1, -1, -1), (x+1, W)]:
            for x2 in range(*r):
                if S[y][x2] == "#":
                    break
                group[y][x2] = group_num
        group_num += 1

for y in range(H):
    if group[y][0] == 0:
        continue
    for r in [(y-1, -1, -1), (y+1, H)]:
        for y2 in range(*r):
            if group[y2][0] > 0:
                break
            group[y2] = group[y]

for l in group:
    print(*l)

Measured memory_bytes: 7576
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define     fi              first
#define     se              second
#define		pb              push_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		ss              ' '
#define     pii             pair<ll,ll>
const double eps = 1e-8;
string s[1006];
ll dp[1006][1006];
const ll  mod= 1e9+7;
ll n,m;
ll ans=0;
ll solve(ll i,ll j)
{
    if(i==n-1&&j==m-1)
    {

        return dp[i][j]=1;

    }
    else if(i>=n||j>=m||s[i][j]=='#')
        return 0;

    if(dp[i][j]!=-1)
        return dp[i][j];

    return dp[i][j]=(solve(i+1,j)%mod+solve(i,j+1)%mod)%mod;

}

int main()
{
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    for(ll i=0; i<n; i++)
        cin>>s[i];
    ll ks= solve(0,0);

    cout<<ks<<nn;


}








Measured memory_bytes: 9344
package main

import (
	"fmt"
	"strconv"
	"strings"
)

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

	arr := strings.Split(n, "")
	fmt.Printf("%d\n", solve(arr))
}

func solve(arr []string) int {
	c1, _ := strconv.Atoi(arr[0])
	c2 := c1 + 1

	n, _ := strconv.Atoi(arr[0] + arr[1] + arr[2])
	m, _ := strconv.Atoi(arr[0] + arr[0] + arr[0])
	if n <= m {
		return c1*100 + c1*10 + c1
	} else {
		return c2*100 + c2*10 + c2
	}
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

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

using namespace std;

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

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	string s[3];
	REP(i, 3) cin >> s[i];
	cout << s[0][0] << s[1][1] << s[2][2];
	system("pause");
	return 0;
}

Measured memory_bytes: 504