akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,n,a[1000],mx,flg,x,xx,suu,su2;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	mx=-1;
	for(i=0;i<n-1;i++)	{
		for(j=i+1;j<n;j++)	{
			x=a[i]*a[j];
			flg=1;	xx=x;
			suu=xx%10;
			xx/=10;
			while(xx>0)	{
				su2=xx%10;
				if(su2!=suu-1)	{
					flg=0;	break;
				}
				suu=su2;
				xx/=10;
			}
			if(flg==1)	{
				mx=max(x,mx);
			}
		}
	}
	printf("%d\n",mx);
	return 0;
}
	


Measured memory_bytes: 2756
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
int n, ans, a[N], val[N], S;
int vis[N], f[N];

int sol(int S) {
    if(!S) return 0;
    if(vis[S]) return f[S];
    f[S] = 0x3f3f3f3f;
    vis[S] = 1;
    for(int i = 1 ; i <= 15 ; ++ i) {
        if(S & (1 << i)) {
            for(int j = 1 ; j <= 15 ; ++ j) {
                if(i != j && (S & (1 << j))) {
                    int t = i ^ j;
                    if(S & (1 << t)) {
                        f[S] = min(f[S], sol(S ^ (1 << i) ^ (1 << j) ^ (1 << t)) + 2);
                    } else {
                        f[S] = min(f[S], sol(S ^ (1 << i) ^ (1 << j) ^ (1 << t)) + 1);
                    }
                }
            }
        }
    }
    return f[S];
}

int main() {
    scanf("%d", &n);
    for(int i = 1, u, v, w ; i < n ; ++ i) {
        scanf("%d%d%d", &u, &v, &w);
        a[u] ^= w;
        a[v] ^= w;
    }
    for(int i = 0 ; i < n ; ++ i) {
        ++ val[a[i]];
    }
    for(int i = 1 ; i <= 15 ; ++ i) {
        ans += val[i] / 2;
        if(val[i] % 2 == 1) {
            S ^= 1 << i;
        }
    }
    printf("%d\n", ans + sol(S));
}


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

int count(ll x){
	int cnt=0;
	while(x>0) x/=10,++cnt;
	return cnt;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll n;
	cin>>n;
	int res=99;
	for(ll i=1;i*i<=n;++i)
		if(n%i==0){
			ll x=i;
			ll y=n/i;
			res=min(res,max(count(i),count(n/i)));
		}
	cout<<res<<'\n';
}




Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

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

    double sum = 0;
    for (int i = 0; i < N; i++) {
      sum+= (double)1/sc.nextInt();
    }


      System.out.println((double)1/sum);


  }

}


Measured memory_bytes: 22612
import java.util.Scanner;

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

		String str = "x";
		for(int i = 0; i < s.length()-1;i++){
			str = str + "x";
		}
		System.out.println(str);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int x,co=1;
        while(true){
            x = s.nextInt();
            if(x==0)break;
            else System.out.println("Case "+co+": "+x);
            co++;
        }
    }
}


Measured memory_bytes: 43188
#include <bits/stdc++.h>
#define INF 1000000000000000001
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  for (ll n = 1; n <= 3500; ++n)
  {
    for (ll h = 1; h <= 3500; ++h)
    {
      ll temp = 4 * h * n - N * n - N * h;
      if (temp <= 0)
      {
        continue;
      }
      if (((N * n * h) % temp) == 0)
      {
        cout << n << ' ' << h << ' ' << ((N * n * h) / (temp)) << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 100000;
int prime[N], is_prime[N];
int cnt = 1;
void gao(){
    for(int i = 2; i < 55555; ++i){
        if(!is_prime[i]){
            prime[cnt++] = i;
        }
        for(int j = 1; j < cnt && 1ll * prime[j] * i < N; ++j){
            is_prime[i*prime[j]] = 1;
            if(i % prime[j] == 0) break;
        }
    }
}
int main(){
    memset(is_prime, 0, sizeof is_prime);
    gao();
    int n;
    scanf("%d", &n);
    int num = 0, i = 1;
    while(num < n){
        if(prime[i] % 10 == 1){
            printf("%d ", prime[i++]);
            num++;
        }else i++;
    }
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for (int i=0; i <(n); ++i)
using namespace std;

long double PI = acos(-1);

int main() {
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  long double jisin, hunsin, kakudo;
  long double theta, result;
  jisin = 360.0 * ((60.0*H+M)/720.0);
  hunsin = 360.0 * M/60.0;
  if (jisin > hunsin){  
    kakudo = jisin - hunsin;
  }
  if (jisin <= hunsin){  
    kakudo = hunsin - jisin;
  }
  theta = (kakudo/360.0)*2.0*PI;
  result = (long double)(A*A+B*B)-(long double)(2*A*B)*cosl(theta);
  cout << scientific << setprecision(10) << sqrtl(result) << endl;
  
  return 0;
}



Measured memory_bytes: 4160
import java.io.IOException;
import java.util.Scanner;

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

        String inputNum = sc.next();

        if(inputNum.matches(".*7.*")) {
            answer = "Yes";
        }

        System.out.println(answer);
        sc.close();
    }
}


Measured memory_bytes: 35736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}

const int N = 100100;
ll dp[N];
ll r[N];

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	r[1] = 1;
	for (int x = 2; x < N; x++)
		r[x] = sub(0, mult(r[MOD % x], MOD / x));

	ll sum = 0;
	for (int i = 1; i < N; i++) {
		dp[i] = add(1, mult(sum, r[i]));
		sum = add(sum, dp[i]);
	}

	ll ans = 0;
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		ll x;
		scanf("%lld", &x);
		ans = add(ans, mult(x, sub(add(dp[i + 1], dp[n - i]), 1)));
	}
	for (int i = 1; i <= n; i++)
		ans = mult(ans, i);
	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 1792
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll h;
  cin >> h;
  ll ans = 0;
  ll mons = 1;
  while(h){
    ans += mons;
    h /= 2;
    mons *= 2;
  }
  print(ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int N;
		cin>>N;
		if(N == 0) break;
		int size = 0;
		ll res = 0;
		vector<string> s(N);
		map<char, P> omomi;
		int perm[10];
		vector<int> out;
		REP(i, 10) {
			perm[i] = (int)i;
		}
		REP(i, N) cin>>s[i];
		REP(i, N) {
			REP(j, s[i].size()) {
				if(omomi.count(s[i][s[i].size() - 1 - j]) == 0) {
					omomi[s[i][s[i].size() - 1 - j]].first = 0;
					omomi[s[i][s[i].size() - 1 - j]].second = 0;
					++size;
				}
				if(i != N - 1) omomi[s[i][s[i].size() - 1 - j]].first += pow(10, j);
				else omomi[s[i][s[i].size() - 1 - j]].second += pow(10, j);
			}
		}
		map<char, P>::iterator ite3 = omomi.begin();
		int foo = 0;
		while(ite3 != omomi.end()) {
			REP(i, N) {
				if(s[i].size() > 1 && s[i][0] == (*ite3).first) {
					out.pb(foo);
					break;
				}
			}
			++ite3;
			++foo;
		}
		P sugoi[10];
		ite3 = omomi.begin();
		REP(i, size) {
			sugoi[i] = (*ite3).second;
			++ite3;
		}

		do {
			ll l = 0, r = 0;
			bool cont = false;
			REP(i, out.size()) {
				if(perm[out[i]] == 0) {
					cont = true;
					break;
				}
			}
			if(cont) continue;
			REP(i, size) {
				l += perm[i] * sugoi[i].first;
				r += perm[i] * sugoi[i].second;
			}
			if(l == r) ++res;
		} while(next_permutation(perm, perm + 10));

		ll hoge = 1;
		REP(i, 10 - size) hoge *= 10 - size - i;
		cout<<res / hoge<<endl;
	}
}

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

int main()
{
    int k,s;
    cin >> k >> s;
    int z,cnt;
    cnt = 0;
    for(int i = 0;i <= k;i++){
        for(int j = 0;j <= k;j++){
            z = s - i - j;
            if(z >= 0 && z <= k) cnt++;
        }
    }
    cout << cnt << endl;
}


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

 
int main() {
  int n;
  cin >> n;
  vector<ll> b(n-1);
  rep(i, n-1) cin >> b.at(i); 
  
  int ans = b.at(0);
  for(int i=1; i < n-1; i++){
    if(b.at(i-1) <= b.at(i)) ans += b.at(i-1);
    else ans += b.at(i);
  }
  ans += b.at(n-2);
   
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
 
struct Node{
    int key;
    Node *right,*left,*parent;
};
 
Node *root, *NIL;
 
void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;
     
    z = (Node *)malloc(sizeof(Node));
    z->key   = k;
    z->left  = NIL;
    z->right = NIL;
     
    while(x != NIL) {
        y = x;
        if(z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
     
    z->parent = y;
    if(y == NIL) {
        root = z;
    } else {
        if( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}
 
void inorder(Node *u) {
    if(u == NIL) return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node *u) {
    if(u == NIL) return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}
     
int main(void) {
    int n, i, x;
    string com;
    scanf("%d",&n);
     
    for(i=0;i<n;i++) {
        cin >> com;
        if(com == "insert") {
            scanf("%d",&x);
            insert(x);
        } else if(com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
 
    return 0;
}


Measured memory_bytes: 26756
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
int main(){
    int a,b;
    cin>>a>>b;
    if(b%a) cout<<b-a<<endl;
    else cout<<b+a<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		int s = 0;
		int b = 1000;
		sc.close();
		for(int i=1; i<=N; i++) {
			int c = L + i -1;
			if(Math.abs(c)<Math.abs(b)) {
				b = c;
			}
		}
		for(int i=1; i<=N; i++) {
			s += L + i -1;
		}
		s -= b;
		System.out.println(s);
	}

}

Measured memory_bytes: 22736
main ::IO()
main = do
    v<-getLine
    print $ solver v



solver::String -> Int
solver str = 
    if elem str r0 then 0 else if
        elem str r1 then 1 else if 
        elem str r2 then 2 else 3 

    
r0::[String]
r0 = ["SSS"]

r1::[String] 
r1 = ["RSS","SRS","SSR","RSR"]

r2::[String]
r2 = ["RRS","SRR"]

r3::[String]
r3 = ["RRR"]

Measured memory_bytes: 3764
import math
if __name__ == '__main__':

	while True:
		try:
			x = int(input())
			h = int(input())

			if x == 0 and h == 0:
				break

			n = math.sqrt(h ** 2 + (x / 2) ** 2) 
			ans = (x ** 2) + (x * n * 0.5) * 4
			print('{:.5f}'.format(ans))

		except EOFError:
			break




Measured memory_bytes: 5676
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))




int main(){
	int N;cin>>N;
	string str;cin>>str;
	int len=SZ(str);
	int res=0;
	REP(i,N){
		string temp;
		cin>>temp;
		if(SZ(temp)<len)continue;
		
		int a=0,b=0;
		bool ch=false;
		while(!ch){
			string::size_type index=temp.find(str[0],a);
			if(index==string::npos)break;
			a=(int)index;
			b=a;
			while(!ch){
				index=temp.find(str[1],b);
				if(index==string::npos)break;
				b=(int)index;
				int gp=b-a;
				int st=a;
				ch=true;
				REP(j,len){
					if(st>=SZ(temp)){
						ch=false;
						break;
					}
					if(temp[st]==str[j])st+=gp;
					else{
						ch=false;
						break;
					}
					
				}
				b++;
			}
			a++;
		}
		if(ch)res++;
	}
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1208
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
#define endl '\n'
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S;
    in >> S;
    //vector<ll> X(N);

    if(S == "Sunny")out << "Cloudy" << endl;
    if(S == "Cloudy")out << "Rainy" << endl;
    if(S == "Rainy")out << "Sunny" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	if (s[2] == s[3] and s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";
}

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

int hap[100000][3];

int maxhap(int ar[][3],int n,int cur,int flag)
{
    if(cur==n){
        return 0;
    }
    if(cur==0){
        int a=ar[0][0]+maxhap(ar,n,cur+1,0);
        int b=ar[0][1]+maxhap(ar,n,cur+1,1);
        int c=ar[0][2]+maxhap(ar,n,cur+1,2);
        if(a>=b && a>=c){
            return a;
        }
        else if(b>=a && b>=c){
            return b;
        }
        else if(c>=a && c>=b){
            return c;
        }
    }
    if(flag==0){
        int a,b;
        if(hap[cur][1]!=-1){
            a=hap[cur][1];
        }
        else{
            a=hap[cur][1]=ar[cur][1] + maxhap(ar,n,cur+1,1);
        }
        if(hap[cur][2]!=-1){
            b=hap[cur][2];
        }
        else{
            b=hap[cur][2]=ar[cur][2] + maxhap(ar,n,cur+1,2);
        }
        return max(a,b);
    }
    if(flag==1){
        int a,b;
        if(hap[cur][0]!=-1){
            a=hap[cur][0];
        }
        else{
            a=hap[cur][0]=ar[cur][0] + maxhap(ar,n,cur+1,0);
        }
        if(hap[cur][2]!=-1){
            b=hap[cur][2];
        }
        else{
            b=hap[cur][2]=ar[cur][2] + maxhap(ar,n,cur+1,2);
        }
        return max(a,b);
    }
    if(flag==2){
        int a,b;
        if(hap[cur][1]!=-1){
            a=hap[cur][1];
        }
        else{
            a=hap[cur][1]=ar[cur][1] + maxhap(ar,n,cur+1,1);
        }
        if(hap[cur][0]!=-1){
            b=hap[cur][0];
        }
        else{
            b=hap[cur][0]=ar[cur][0] + maxhap(ar,n,cur+1,0);
        }
        return max(a,b);
    }
}

int main()
{
    int n;
    cin>>n;
    int ar[n][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin>>ar[i][j];
        }
    }
    for(int i=0;i<n;i++){
        fill(hap[i],hap[i]+3,-1);
    }
    for(int i=0; i<3; i++){
        hap[n-1][i]=ar[n-1][i];
    }
    cout << maxhap(ar,n,0,0);
}





Measured memory_bytes: 10368
N = int(input())
As = list(map(int, input().split()))
ss = [0]
for A in As:
  ss.append(ss[-1]+A)
ds = []
for i in range(N):
  l = ss[i]
  d = abs(2*l-ss[-1])
  ds.append(d)
r = min(ds)
print(r)


Measured memory_bytes: 29964
using System;
using System.Linq;

namespace ABC084_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var S = Console.ReadLine();
            bool f = true;

            for (int i = 0; i < S.Length; i++)
            {
                if (i != AB[0] && !char.IsDigit(S[i])) f = false;
                if (i == AB[0] && !(S[i] == '-')) f = false;
            }
            Console.WriteLine(f ? "Yes": "No");
        }
    }
}


Measured memory_bytes: 13396
#include <stdio.h>

int main (void) {
  int i;
  char S[6];
  
  scanf("%s", S);
  
  if ( S[2] == S[3] && S[4] == S[5] ) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
import Control.Applicative
import Control.Monad
import Data.Array
import Data.Array.ST
import Data.List
import qualified Data.Map as M
import qualified Data.Set as S
import Text.Printf

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

main :: IO ()
main = do
  n <- readLn
  bfrvs <- replicateM n readInts
  let ary = solve bfrvs
  forM_ [1..4] $ \b -> do
    forM_ [1..3] $ \f -> do
      forM_ [1..10] $ \r -> do
        printf " %d" (ary ! (b, f, r))
      putChar '\n'
    when (b /= 4) $ putStrLn $ replicate 20 '#'

solve :: [[Int]] -> Array (Int, Int, Int) Int
solve bfrvs = runSTArray $ do
  ary <- newArray ((0,0,0),(4,3,10)) 0
  forM_ bfrvs $ \[b,f,r,v] -> do
    v0 <- readArray ary (b, f, r)
    writeArray ary (b, f, r) (v0 + v)
  return ary



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

int main()
{
    int h,n;
    cin >> h >> n;
    int a[1000000];
    for(int i=0;i<n;i++) { 
        cin >> a[i];
        int b = a[i];
        h -= b;
        if(h<=0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main()
{
    char a[100005];
    scanf("%s",&a);

    int n=strlen(a);

    int p=0,q=0;

    for(int i=0; i<n-1; i++)
    {
        if(a[i]==a[i+1])
        {
            q=i+1;
            break;
        }
    }
    for(int i=0; i<n-2; i++)
    {
        if(a[i]==a[i+2])
        {
            p=i+1;
            break;
        }
    }
    if(q!=0)
        printf("%d %d\n",q,q+1);
    else if(p != 0)
        printf("%d %d\n",p,p+2);
    else
        printf("-1 -1\n");


    return 0;
}


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	ll n;
	cin >> n;
	stack<int> q;
	ll r = -2;
	for (ll i = 1; n != 0; i++) {
		if (abs(n) % abs(r) != 0) {
			n -= (r/-2);
			q.push(1);
		}
		else q.push(0);
		r *= (-2);
		//cout << n;
	}
	if (q.empty())cout << 0;
	while (!q.empty()) {
		int a = q.top(); q.pop();
		cout << a;
	}
	cout << endl;
}


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

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

  int64_t A, B, C, D;
  cin >> A >> B;
  C = __gcd(A, B);
  D = C;
  int64_t ans = 1;
  if(C == 1){
    cout << ans << endl;
    return 0;
  }
  for(int64_t i=2;i*i<=C;i++){
    if(D % i == 0){
      D /= i;
      ans++;
      while(true){
        if(D % i == 0){
          D /= i;
        }
        else break;
      }
    }
    if(D == 1){
      break;
    }
  }
  if(D != 1) ans++;

  cout << ans << endl;

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll a = in(), b = in();
	cout << a - (b < a ? 1 : 0) << endl;
}

Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+100;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vvi G;
vi used;
int st=-1,go=-1;
vi f(int a){
	vvi t;
	rep(i,G[a].size())if(used[G[a][i]]==0){
		int to=G[a][i];
		if(a==st&&to==go)continue;
		if(to==st&&a==go)continue;
		
		used[G[a][i]]=true;
		t.pb(f(G[a][i]));
	}
	if(t.size()==0)return vi{1};

	int ma=0;
	rep(i,t.size())ma=max(ma,(int)t[i].size());
	vi out(ma+1);
	out[0]=1;
	out[1]=t.size();
	int q=t.size();
	loop(i,1,ma){
		int m=0;
		rep(j,t.size())if(i<t[j].size())
			m=max(m,t[j][i]/t[j][i-1]);
		out[i+1]=m*q;
		q*=m;
	}
	
//	if(st==2&&go==3){
//	cout<<a<<endl;rep(i,out.size())cout<<" "<<out[i];cout<<endl;}
	return out;
}
signed main(){
	cin>>n;
	G=vvi(n+1);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	int out=inf,out1=inf;
	rep(i,n){
		used=vi(n);
		used[i]=true;
		vi w=f(i);
		int sum=1;
		rep(j,w.size())sum*=w[j];
		pii t(w[w.size()-1],w.size());
//		rep(j,w.size())cout<<" "<<w[j];cout<<endl;
		if(out>t.second){
			out=t.second;
			out1=t.first;
		}else if(out==t.second)
			out1=min(out1,t.first);
//	cout<<t.first<<" "<<t.second<<endl;
	}
	rep(i,n)rep(j,G[i].size()){
		G[n]=vi(0);
		used=vi(n+1);
		st=i,go=G[i][j];
		G[n].pb(st);
		G[n].pb(go);
		vi w=f(n);
		pii t(w[w.size()-1],w.size()-1);
//		cout<<i<<" "<<go<<endl;
//		rep(j,w.size())cout<<" "<<w[j];cout<<endl;
		if(out>t.second){
			out=t.second;
			out1=t.first;
		}else if(out==t.second)
			out1=min(out1,t.first);

	}
	cout<<out<<" "<<out1<<endl;
}







Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, ll> P;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> c(m);
    rep(i, n)
    {
        int k;
        cin >> k;
        rep(i, k)
        {
            int a;
            cin >> a;
            a--;
            c[a]++;
        }
    }
    int ans = 0;
    rep(i, m)
    {
        if (c[i] == n)
        {
            ans++;
        }
    }
    cout << ans << endl;
}

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

if 1==n:
    print("1")
elif 2<=n<4:
    print("2")
elif 4<=n<8:
    print("4")
elif 8<=n<16:
    print("8")
elif 16<=n<32:
    print("16")
elif 32<=n<64:
    print("32")
elif 64<=n:
    print("64")


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

    for(int i=0; i<N; i++){
        int A;
        cin >> A;
    }

    for(int i=1; i<=N; i++)
        if(K*i-(i-1) >= N){
            cout << i << endl;
            return 0;
        }
    return 0;
}

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

int main(void) {
  int A,B,C;
  cin >> A >> B >> C;
  int arr[100+1];
  for(int i=0; i<101; ++i) {
    arr[i]=i;
  }
  for(int i=0; i<abs(A-B);) {
      if(A>B) {
	if(arr[B+i+1]==C) {
	  cout << "Yes" << "\n";
	  return 0;
	}
	++i;
      }
      else {
	if(arr[A+i+1]==C) {
	  cout << "Yes" << "\n";
	  return 0;
	}
	++i;
      }
  }
  cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    ll a,b,ans;cin>>a;
   string s;cin>>s;
   ans=a;
   b=1;
   rep(i,a-1){
               if(s[i]!=s[i+1]){
                                b++;
                                }
              }
              
   
         cout<<b<<endl; 
         
}




Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7; 

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF_INT (1<<30)
#define INF_LL (1ll<<62)

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


ll mod = 1000000007;
//---------------------------------------------------------------------------------------------------
ll f[2010100], rf[2010100];
ll inv(ll x) {
    ll res = 1;
    ll k = mod - 2;
    ll y = x;
    while (k) {
        if (k & 1) res = (res * y) % mod;
        y = (y * y) % mod;
        k /= 2;
    }
    return res;
}
void init() {
    f[0] = 1;
    repi(i, 1, 2010010) f[i] = (f[i - 1] * i) % mod;
    repi(i, 0, 2010010) rf[i] = inv(f[i]);
}
//---------------------------------------------------------------------------------------------------
ll C(int n, int k) {
    ll a = f[n]; // = n!
    ll b = rf[n-k]; // = (n-k)!
    ll c = rf[k]; // = k!

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

ll fun(ll r, ll c){
    if(r==0&&c==0)return 1;
    else if(r==0||c==0)return max(r,c)+1;
    ll ans = 0;
    rep(i,c+1)ans = (ans + C(r+1+i,i+1)) % mod;
    return ans;
}

ll r1,r2,c1,c2;

int main(){
    cin>>r1>>c1>>r2>>c2;
    init();
    out((fun(r2,c2) - fun(r1-1,c2) - fun(r2, c1-1) + fun(r1-1,c1-1) + mod + mod)%mod);
}

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


using namespace std;


const int MAXN = 100 * 1000 + 23, MAXD = 10 + 3;








int n, m, q, a[MAXN], c[MAXN], d[MAXN], r[MAXD][MAXN];
vector<int> g[MAXN];

void dfs(int, int, int);

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[--u].push_back(--v), g[v].push_back(u);
    }
    cin >> q;
    for (int i = 0; i < q; i++)
        cin >> a[q - i - 1] >> d[q - 1 - i] >> c[q - i - 1], a[q - i - 1]--;
    for (int i = 0; i < q; i++)
        dfs(a[i], d[i], c[i]);
    for (int i = 0; i < n; i++)
        cout << r[0][i] << '\n';
    return 0;
}
void dfs(int v, int d, int c) {
    if (d < 0 || r[d][v] != 0) return;
    else for (int i = d; ~i; i--) if (r[i][v] == 0) r[i][v] = c; else break;
    for (auto u : g[v]) dfs(u, d - 1, c);
}

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

const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
const int INF = 0x3fffffff;
int h, w;
vector<string> s;
vector<vector<int>> bfs(int x, int y){
    vector<vector<int>> cost(h, vector<int>(w, INF));
    cost[x][y] = 0;
    queue<pair<int, int>> q;
    q.emplace(x, y);
    while(q.size()){
        int x, y;
        tie(x, y) = q.front();
        q.pop();
        for(int i = 0; i < 4; i++){
            int x2 = x + dx[i], y2 = y + dy[i];
            if(x2 < 0 || x2 >= h || y2 < 0 || y2 >= w || s[x2][y2] == '#') continue;
            if(cost[x2][y2] > cost[x][y] + 1){
                cost[x2][y2] = cost[x][y] + 1;
                q.emplace(x2, y2);
            }
        }
    }
    return cost;
}
int main(){
    cin >> h >> w;
    s.resize(h);
    for(auto&& i : s) cin >> i;
    int ans = 0;
    for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(s[i][j] != '#'){
        auto cost = bfs(i, j);
        for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) if(s[i][j] != '#' && ans < cost[i][j]) ans = cost[i][j];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*input
8
WRWWRWRR
*/
 
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <climits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
#include <tgmath.h>
 
using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define ar array
#define scd(t) scanf("%d",&t)
#define scld(t) scanf("%ld",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define tests int r; cin >> r; while(r--)
#define MP make_pair
#define PI acos(-1)
typedef pair<int, int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define godspeed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
 
#define M(x) ((x)%(1000000007))
 

int arr[1010][1010];

int h;
int w;



bool legal(int x, int y){
	if(x>=1&&x<=h){
		if(y>=1&&y<=w){
			if(arr[x][y]){
				return true;

			}
		}
	}
	return false;
}


int main() {
 	int n;
 	cin>>n;
 	string s;
 	cin>>s;
 	int count = 0;
 	rep(i,n){
 		if(s[i]=='R'){
 			count++;
 		}
 	}
 	int ans = 0;
 	rep(i,count){
 		if(s[i]=='W'){
 			ans++;
 		}
 	}
 	cout<<min(count,min(ans,n-count))<<endl;


 	
}



 


Measured memory_bytes: 3732
#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;

int main()
{
  ll N = 5;
  vector<ll> order(N, 0);
  for (auto i = 0; i < N; i++){
    cin >> order[i];
  }
  ll res = 125 * 10;
  do
  {
    ll time = 0;
    for (auto i = 0; i < N - 1; i++)
    {
      time += order[i];
      time += (10 - (time % 10)) % 10;
    }
    time += order[N - 1];
    res = min(res, time);
  } while (next_permutation(order.begin(), order.end()));

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
  val scanner = Scanner(System.`in`)
  val a = scanner.nextInt()
  scanner.nextInt()
  scanner.nextInt()
  scanner.nextInt()
  val e = scanner.nextInt()
  println(if (e - a <= scanner.nextInt()) "Yay!" else ":(")
  scanner.close()
}

Measured memory_bytes: 31128
// Problem : A - Not
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std ;

#define int int64_t
#define all(a) (a).begin(), (a).end()

int32_t main(){ 
   ios::sync_with_stdio(false) ; 
   cin.tie(0) ;
   int x ;
   cin >> x ;
   cout << !x ;
	return 0 ;
}

Measured memory_bytes: 3608
inl = list(map(int,input().split()))
a = inl[0]
b = inl[1]
c = inl[2]
d = inl[3]


outl = []
outl.append(a*c)
outl.append(a*d)
outl.append(b*c)
outl.append(b*d)


print(max(outl))


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

#define LL long long
#define PLL pair<LL,LL>

using namespace std;

const LL MAXN = 1000047;
const LL INF = 1000000000;

struct Vertex{
	LL l,r;
	PLL v;
	Vertex *lc,*rc;

	Vertex(LL _l, LL _r){
		l = _l;
		r = _r;
		v = {INF,l};
		if (r-l > 1){
			LL mid = (l+r)/2;
			lc = new Vertex(l,mid);
			rc = new Vertex(mid,r);
		}
		else{
			lc = nullptr;
			rc = nullptr;
		}
	}

	void update(LL _l, LL _v){
		if (r-l == 1){
			v = {_v,l};
			return;
		}
		if (_l >= rc->l){
			rc->update(_l,_v);
		}
		else{
			lc->update(_l,_v);
		}
		v = min(lc->v,rc->v);
	}

	PLL query(LL _l, LL _r){
		if (_l >= r || _r <= l){
			return {INF,INF};
		}
		if (_l <= l && _r >= r){
			return v;
		}
		return min(lc->query(_l,_r),rc->query(_l,_r));
	}

	PLL query2nd(LL _l, LL _r){
		PLL p = query(_l,_r);
		update(p.second,INF);
		PLL res = query(_l,_r);
		update(p.second,p.first);
		return res;
	}
};

int main(){
	ios_base::sync_with_stdio(false);
	LL n;
	cin >> n;
	vector<LL> a(n);
	for (LL i = 0; i < n; i++)
		cin >> a[i];
	Vertex *left = new Vertex(0,MAXN);
	Vertex *right = new Vertex(0,MAXN);
	for (LL i = 0; i < n; i++)
		right->update(a[i],i);
	LL res = 0;
	for (LL i = 0; i < n; i++){
		LL subs = 0;
		right->update(a[i],INF);
		LL r1 = (right->query(a[i]+1,MAXN)).first;
		LL r2 = (right->query2nd(a[i]+1,MAXN)).first;
		LL l1 = (left->query(a[i]+1,MAXN)).first;
		LL l2 = (left->query2nd(a[i]+1,MAXN)).first;
		// no larger on the left
		if (l1 != INF)
			l1 *= (-1);
		if (l2 != INF)
			l2 *= (-1);
		if (l1 == INF){
			if (r1 != INF){
				if (r2 == INF){
					subs += (n-r1)*(i+1);
				}
				else{
					subs += (r2-r1)*(i+1);
				}
			}
		}
		else{
			if (r1 != INF){
				if (r2 == INF){
					subs += (n-r1)*(i-l1);
				}
				else{
					subs += (r2-r1)*(i-l1);
				}
			}
		}
		// no larger on the right
		if (r1 == INF){
			if (l1 != INF){
				if (l2 == INF){
					subs += (n-i)*(l1+1);
				}
				else{
					subs += (n-i)*(l1-l2);
				}
			}
		}
		else{
			if (l1 != INF){
				if (l2 == INF){
					subs += (r1-i)*(l1+1);
				}
				else{
					subs += (r1-i)*(l1-l2);
				}
			}
		}
		left->update(a[i],-i);
		res += a[i]*subs;
	}
	cout << res << "\n";
}


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

int main(){
	while(1){
		int n, k;
		long s[100];
		scanf(" %d %d", &n, &k);
		if(n==0 && k==0) break;
		for(int i=0; i<k; ++i) scanf(" %ld", &s[i]);
		for(int i=0; i<n; ++i){
			for(int j=0; j<k; ++j){
				int b;
				scanf(" %d", &b);
				s[j]-=b;
			}
		}
		
		bool ans=true;
		for(int i=0; i<k; ++i){
			if(s[i]<0) ans=false;
		}
		
		if(ans) printf("Yes\n");
		else printf("No\n");
	}
}

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

int main(void) {
  int N, d, cnt, ans=0;
  cin >> N;
  
  for(int i=1; i<=N; i++){
    cnt=0;
    d=i;
    while(d>0){
      d /= 10;
      cnt++;
    }
    if(cnt % 2 != 0) ans++;
  }
  
  cout << ans << endl;

  return 0;
}

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

def same_tree(node_a, node_b):
    if node_a.root() == node_b.root():
        return True

def unite(node_a, node_b):
    root_a = node_a.root()
    root_b = node_b.root()
    if root_a == root_b:
        return
    if root_b.depth > root_a.depth:
        root_a, root_b = root_b, root_a
    root_b.is_root = False
    root_b.parent = root_a
    root_a.depth = max(root_a.depth, root_b.depth+1)

class Node:
    def __init__(self):
        self.is_root = True
        self.parent = None
        self.depth = 1
    
    def root(self):
        node = self
        while not node.is_root:
            node = node.parent
        return node

def main():
    N, M = map(int, input().split())
    p = list(map(int, input().split()))

    nodes = [Node() for i in range(N)]

    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        unite(nodes[a], nodes[b])
    
    ans = 0
    for i in range(N):
        if same_tree(nodes[i], nodes[p[i]-1]):
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
int n,c=0;
cin >> n;
int a[n];
for(int i=0;i<n;i++)
  cin >> a[i];
  
for(int i=1;i<n-1;i++)
  if((a[i]<a[i-1] && a[i]>a[i+1]) || (a[i]>a[i-1] && a[i]<a[i+1]))
    c++;
cout << c;

}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swap(数値交換)
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　（A＋B）÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
	int n;
	cin >> n;
	asas;
	if (n >= 10000) {
		if (n >= 100000) {
			ans += 90000;
		}
		else ans += n - 9999;
	}
	if (n >= 100) {
		if (n >= 1000) {
			ans += 900;
		}
		else ans += n - 99;
	}
	if (n > 0) {
		if (n >= 10) {
			ans += 9;
		}
		else ans += n;
	}
	cout << ans << rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
    Mbak Seulgi Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 1e9+7;
int n;
ll dp[1000010][2][2];
ll dfs(int pos, bool zero, bool nine)
{
    if(pos == n && zero && nine) return 1;
    else if(pos == n) {
        return 0;
    }
    if(dp[pos][zero][nine] != -1) return dp[pos][zero][nine];
    ll ret = 0;
    for(int i = 0; i < 10; i++) {
        ret += dfs(pos + 1, zero || (bool)(i==0), nine || (bool)(i==9));
        ret %= mod;
    }
    return dp[pos][zero][nine] = ret;
}
int main()
{
    int i,j,k,x,y,ans,curr,temp,m;
    int tc;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    cout << dfs(0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 128488
s = input()

C = list(set(list(map(str, s))))

ans = len(s)
for c in C:
	tmp = 0
	cnt = 0
	for i in range(len(s)):
		if s[i] == c:
			tmp = max(tmp, cnt)
			cnt = 0
		else:
			cnt += 1

	tmp = max(tmp, cnt)
	ans = min(ans, tmp)

print(ans)

Measured memory_bytes: 3064