akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>

int n;
long long a[100005], t;
int main()
{
	std::cin >> n >> t;
	for (int i = 0; i < n; ++i)
		std::cin >> a[i];

	long long max = 0;
	long long dis = 0;
	int dc = 1, mc = 1;
	for (int i = n - 1; i >= 0; --i) {
		auto d = max - a[i];

		if (d > dis) {
			dis = d;
			dc = 1;
		}
		else if (d == dis)
			++dc;

		if (a[i] > max) {
			max = a[i];
			mc = 1;
		}
		else if (a[i] == max)
			++mc;
	}

	std::cout << dc * mc << std::endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.*; 
import java.lang.*; 


public class Main{
    
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
                
                int N = scan.nextInt();
                
                int cnt = 0;
                for(int i=0; i<N; i++){
                    int a = scan.nextInt();
                    int b = scan.nextInt();
                    
                    if(a==b){
                        cnt++;
                    }else{
                        cnt=0;
                    }
                    
                    if(cnt==3){
                        System.out.println("Yes");
                        System.exit(0);
                    }
                }
                
                System.out.println("No");

        }
}

Measured memory_bytes: 36020
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)
const ll MOD = 1e9 + 7;

ll s[200001] = {};
int main()
{
    int n, k; cin >> n >> k;
    s[0] = 0;
    repe(i, 1, n + 1) s[i] = s[i-1] + i;

    ll ans = 0;
    repe(i, k, n+1) {
        ll a = (s[i - 1] - s[0]);//% MOD;
        ll b = (s[n] - s[n - i]);//% MOD;

        ans = (ans % MOD)+ (b - a  + 1) % MOD;
    }
    cout << ans % MOD << endl;

    return 0;
}



Measured memory_bytes: 5008
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;

int pot[2][100003] , N;
#define PII pair < int , int >
PII mx[2][2];

int main(){
	cin >> N; for(int i = 1 ; i <= N ; ++i){int x; cin >> x; ++pot[i & 1][x];}
	for(int i = 0 ; i <= 1 ; ++i)
		for(int j = 0 ; j <= 1e5 ; ++j){
			PII t(pot[i][j] , j);
			if(t > mx[i][0]){mx[i][1] = mx[i][0]; mx[i][0] = t;}
			else if(t > mx[i][1]) mx[i][1] = t;
		}
	cout << N - (mx[0][0].second == mx[1][0].second ? max(mx[0][0].first + mx[1][1].first , mx[0][1].first + mx[1][0].first) : mx[0][0].first + mx[1][0].first);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    string S;
    cin >> A >> B >> C;

    // cout <<ans<<endl;
    
    // if(A<B)
    // 	cout << 0<<endl;
    // else
    // 	cout <<10<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    if(A+B==C || B+C==A || C+A==B)
    	puts("Yes");
    else
    	puts("No");
    	
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a[101][101];
	int x,y,i1, i2 ,m=0;;

	scanf("%d%d", &y, &x);
	for (i1=0;i1<y;i1++)
	{
		for (i2=0;i2<x;i2++)
		{
			scanf("%d", &a[i2][i1]);
		}
	}
/////////////////////////////////////////

	for (i1=0;i1<y;i1++)//?¨???????????¨?
	{
		m=0;
		for (i2=0;i2<x;i2++)
		{
			m=m+a[i2][i1];
			if (i2==x-1)
			{
				a[x][i1]=m;
			}
		}
	}

	for (i1=0;i1<=x;i1++)
	{
		m=0;
		for (i2=0;i2<y;i2++)
		{
			m=m+a[i1][i2];
			if (i2==y-1)
			{
				a[i1][y]=m;
			}
		}
	}





//////////////////////////////////////////
	for (i1=0;i1<=y;i1++)
	{
		
		for (i2=0;i2<=x;i2++)
		{
			printf("%d", a[i2][i1]);
			if (i2<x)
			{
				printf(" ");
			}
		}

	printf("\n");
	}

	//printf("\n");

	return 0;
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=getchar();
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    int n;
    cin >> n;
    long long int a[n];
    long long int mon=1000;
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=1;i<n;i++){
        if(a[i]>a[i-1])mon+=(mon/a[i-1])*(a[i]-a[i-1]);
    }
    cout << mon;
	return 0;
}



Measured memory_bytes: 3612
package main

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

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		return []byte(f1())
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	r := readInt()
	println(r * r)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 640
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

ll parent(ll i)
{
	return i / 2;
}
ll left(ll i)
{
	return 2 * i;
}
ll right(ll i)
{
	return 2 * i + 1;
}

int main()
{
	v.push_back(ans);
	cin >> n;
	REP(i, n)
	{
		cin >> k;
		v.push_back(k);
	}
	REP1(i, n)
	{
		cout << "node " << i << ": key = " << v[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << v[parent(i)] << ", ";
		if (left(i) <= n) cout << "left key = " << v[left(i)] << ", ";
		if (right(i) <= n) cout << "right key = " << v[right(i)] << ", ";
		cout << endl;
	}
}

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

int main()
{
  int n, k; cin >> n >> k;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  vector<double> q(n + 1);
  q[0] = 0;
  for (int i = 1; i <= n; i++) q[i] = q[i - 1] + (double)(p[i - 1] + 1) / 2;
  double ans = 0;
  rep(i, n - k + 1) ans = max(ans, q[i + k] - q[i]);
  printf("%f\n", ans);
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template<class T> int former(const vector<T> &v, T x) {
    return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x) {
    return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int main()
{
    int a, b, q; cin >> a >> b >> q;
    vector<ll> s(a), t(b);
    rep(i, a) cin >> s[i];
    rep(i, b) cin >> t[i];
    s.push_back(INF);s.push_back(-INF); sort(ALL(s));
    t.push_back(INF);t.push_back(-INF); sort(ALL(t));

    rep(_, q)
    {
        ll x; cin >> x;
        ll ans = INF;

        rep(i, 2)
        {
            ll first = (i ? s[former(s, x)] : s[latter(s, x)]);
            rep(j, 2)
            {
                ll second = (j ? t[former(t, first)] : t[latter(t, first)]);
                chmin(ans, abs(x - first) + abs(first - second));
            }
        }

        rep(i, 2)
        {
            ll first = (i ? t[former(t, x)] : t[latter(t, x)]);
            rep(j, 2)
            {
                ll second = (j ? s[former(s, first)] : s[latter(s, first)]);
                chmin(ans, abs(x - first) + abs(first - second));
            }
        }
        cout << ans << endl;
    }
}

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

typedef long long ll;
const int N = 2000006;
const ll MOD = 1e9+7;

int a[N];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n,l;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	int idx = -1;
	for(int i=1;i<n;i++){
		if(a[i]+a[i-1] >= l){
			idx = i-1;
			break;
		}
	}
	if(idx == -1){
		cout<<"Impossible"<<endl;
	}else{
		cout<<"Possible"<<endl;
		for(int i=0;i<idx;i++){
			cout<<i+1<<endl;
		}
		for(int i=n-1;i>idx;i--){
			cout<<i<<endl;
		}
	} 
	
	return 0;
}


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

const int MAX = 1e6+1;

vector<int> tetra;
int all[MAX];
int odd_only[MAX];

void prepare() {
    for (int i=1; i*(i+1)*(i+2)/6<MAX; ++i) {
        tetra.push_back(i*(i+1)*(i+2)/6);
    }

    fill_n(all, MAX, INT_MAX);
    all[0] = 0;
    fill_n(odd_only, MAX, INT_MAX);
    odd_only[0] = 0;

    for (int t: tetra) {
        for (int i=0; i+t<MAX; ++i) {
            all[i+t] = min(all[i+t], all[i]+1);
            if (t % 2) odd_only[i+t] = min(odd_only[i+t], odd_only[i]+1);
        }
    }
}

int main() {
    prepare();
    int n;
    while (cin >> n, n) {
        cout << all[n] << " " << odd_only[n] << endl;
    }
    return 0;
}


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

int main() {  
long long a,b,c;
  cin>>a>>b>>c;
 
if(4*a*b<(c-a-b)*(c-a-b) &&c>a+b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
 
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		if(N%2 == 0) {
			System.out.println(N);
		} else {
			System.out.println(2*N);
		}
		
	}

}

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

int main(){
  int n;
  cin >> n;
  vector<int> v;
  v.push_back(1);
  int val = 6;
  while(val <= n){
    v.push_back(val);
    val *= 6;
  }
  val = 9;
  while(val <= n){
    v.push_back(val);
    val *= 9;
  }
  sort(v.begin(), v.end());
  int ans[n+1];
  for ( int i = 0; i < v.size(); i++){
    ans[v[i]] = 1;
  }
  ans[0] = 0;

  for ( int i = 1; i <= n; i++){
    int minv = 1 << 28;
    for ( int j = 0; j < v.size(); j++){
      if ( v[j] > i)break;
      minv = min ( ans[i - v[j]], minv);
    }
    ans[i] = minv + 1;
  }

  cout << ans[n] << endl;

  return 0;
}

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

typedef pair<int, int> P;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  cout << N*N*N << endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

cnt = 0
l = []
for a in A:
  if a < 0:
    cnt += 1
  l.append(abs(a))

if cnt % 2 == 0:
  ans = sum(l)
else:
  ans = sum(l) - 2*min(l)
print(ans)

Measured memory_bytes: 20132
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {
	int n,k,x,y;
	cin>>n>>k>>x>>y;
	ll sum = 0;
	if(n>=k) {
		sum+=x*k;
		n-=k;
	} else {
		sum+=n*x;
		n=0;
	}
	sum+=n*y;
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3652
N=gets.to_i;v=$<.map{|e|Complex(*e.split.map(&:to_i))};h={};r=2**N+~N;[*0...N].send(*(z=:combination,2)){|i,j|h[x=[i,j]]||((j+1...N).map{|k|((v[j]-v[k]).conj*(v[i]-v[k])).imag==0&&x<<k};r-=2**(l=x.size)+~l;x.send(*z){|e|h[e]=1})};p r%998244353

Measured memory_bytes: 5116
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
  string a, b, c;

  cin >> a >> b >> c;
  transform(a.begin (), a.end (), a.begin (), ::toupper);
  transform(b.begin (), b.end (), b.begin (), ::toupper);
  transform(c.begin (), c.end (), c.begin (), ::toupper);

  cout << a[0] << b[0] << c[0] << endl;

}

Measured memory_bytes: 256
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    N = int(input())
    D, X = map(int, input().split())
    A = [int(input()) for _ in range(N)]
    choco = X
    for a in A:
        choco += ceil(D / a)
    print(choco)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62388
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int A = rei();
	int B = rei();
	int ans = min(A*N,B);
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc096/tasks/abc096_d

#include "algorithm"
#include "iostream"
#include "set"
#include "vector"
#define rep(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;

template <class T>
inline bool chmax(T& a, T b);
template <class T>
inline bool chmin(T& a, T b);

bool is_prime(ll a) {
  if (a == 1) return false;

  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      return false;
    }
  }

  return true;
}

void print_ints(vector<ll> v);

void solve() {
  ll N;
  cin >> N;

  // n ≡ 1 mod 5 なる a のみを含めれば、 5 つ選んだ時に必ず 5
  // の倍数となり条件を満たす。

  vector<ll> v;

  ll next = 2;
  while (v.size() < N) {
    if (is_prime(next) && next % 5 == 1) {
      v.push_back(next);
    }

    next++;
  }

  print_ints(v);
}

#ifndef TEST
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}
#endif

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;
}

void print_ints(vector<ll> v) {
  rep(i, 0, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const LL M=1e9+7;
LL dp[61][3];
int main() {
	LL N;
	scanf("%lld",&N);
	dp[60][0]=1;
	for(int k=59;k>=0;k--){
		for(int r=0;r<=2;r++){
			int v=r*2;
			if(N&(1LL<<k)){
				v+=1;
			}
			for(int i=0;i<=min(2,v);i++){
				dp[k][min(v-i,2)]+=dp[k+1][r];
			}
		}
		for(int i=0;i<3;i++){
			dp[k][i]%=M;
		}
	}
	printf("%lld\n",(dp[0][0]+dp[0][1]+dp[0][2])%M);


	return 0;
}



Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2.0) //等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}
#define nopf(T) [](T a){return a;}
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s;
	scans(s);
	printyn(s.find("A") != string::npos && s.find("B") != string::npos);

	Please AC;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GraphPartition | diff GraphPartition.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GraphPartition.cpp && ./a.out

/*
 
 10/5/2019
 
 14:58-
 
 */

const int MAX_N=200+1;
int N;

VI G[MAX_N];
int mx[MAX_N][MAX_N];
int isb=true;
int viz[MAX_N];
void dfs(int u, int c=0) {
  if(viz[u]!=-1) {
    isb&=(viz[u]==c);
    return;
  }
  viz[u]=c;
  FORR(v,G[u]) dfs(v,c^1);
}
void solve() {
  MINUS(viz);
  dfs(0);
  if(!isb) {
    cout<<-1<<endl;
    return;
  }
  const int Inf=1e8;
  REP(i,N)REP(j,N)if(i!=j&&mx[i][j]==0) mx[i][j]=Inf;
  REP(k,N)REP(i,N)REP(j,N) SMIN(mx[i][j],mx[i][k]+mx[k][j]);
  int res=0;
  REP(i,N)REP(j,N) SMAX(res,mx[i][j]);
  cout<<res+1<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) {
    string s; cin>>s;
    FOR(j,i+1,N) if(s[j]=='1') {
      G[i].push_back(j),G[j].push_back(i);
    }
    REP(j,N) mx[i][j]=(s[j]=='1');
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define loop(i,a,n) for (ll i=a;i<n;i++)
#define loopm(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define Graph(n) vector < vector < ll > > (n,vector < ll >(0,0))
#define tr(container,it)\
for(auto it=container.begin();it!=container.end();it++)
#define SZ(x) ((int)(x).size())
typedef vector<long long> VI;
typedef long long ll;
typedef vector < vector < ll > > VII;
typedef pair<ll,ll> PII;
typedef double db;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    VI height(n,0);
    loop(i,0,n)
    {
        cin>>height[i];
    }

    VI dp(n,0);
    dp[1]=abs(height[1]-height[0]);
    loop(i,2,n)
    {
        dp[i]=min(dp[i-2]+abs(height[i]-height[i-2]),dp[i-1]+abs(height[i]-height[i-1]));
    }
    cout<<dp[n-1];
}


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

d = {
  0: "a",
  1: "b",
  2: "c",
  3: "d",
  4: "e",
  5: "f",
  6: "g",
  7: "h",
  8: "i",
  9: "j"
}

ans = [[0]]

for i in range(n-1):
  new_ans = [
    i + [j]
    for i
    in ans
    for j
    in range(min(10, max(i) + 2))
  ]
  ans = new_ans

for i in ans:
  print("".join(d[j] for j in i))

Measured memory_bytes: 25292
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node
{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key)
{
  NodePointer cur = nil->next;
  while(cur !=nil && cur->key !=key)
    {
      cur = cur->next;
    }
  return cur;
}

void printList()
{
  NodePointer cur = nil->next;
  int isf = 1;
  while(1)
    {
      if(cur == nil)break;
      if(isf == 0)printf(" ");
      printf("%d",cur->key);
      cur = cur->next;
      isf = 0;
    }
  printf("\n");
}

void deleteNode(NodePointer t)
{
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst()
{
  NodePointer t = nil->next;
  if(t == nil)return;
  deleteNode(t);
}

void deleteLast()
{
  NodePointer t = nil->prev;
  if(t == nil)return;
  deleteNode(t);
}

void delete(int key)
{
  NodePointer t = listSearch(key);
  if(t == nil)return;
  deleteNode(t);
}

void init()
{
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void insert(int key)
  {
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
  
}

int main()
{
  int key,n,i;
  int size = 0;
  char com[20];
  int np = 0,nd = 0;
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++)
    {
      scanf("%s%d",com,&key);
      if(com[0]=='i'){insert(key);np++;size++;}
      else if ( com[0] == 'd' )
	{
	  if (strlen(com) > 6)
	    {
	      if ( com[6] == 'F' ) deleteFirst();
	      else if ( com[6] == 'L' ) deleteLast();
	    }
	  else
	    {
	      delete(key); nd++; 
	    }
	  size--;
	}
    }

  printList();
  return 0;
}



Measured memory_bytes: 33036
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(auto&& i : p){
        cin >> i;
    }
    sort(rbegin(p), rend(p));
    p[0] /= 2;
    cout << accumulate(begin(p), end(p), 0) << "\n";
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int a,b,sum,n;
	while (cin >> a >> b)
	{
		n=0;
		sum = a+b;
		while (sum != 0)
		{
			sum /= 10;
			n++;
		}
		cout<<n<<endl;
	}
	return false;
}


Measured memory_bytes: 3008
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int X = sc.nextInt();
        int ans = 0;
        int c500 = Math.min(A,X/500);
        for(int i=0;i<=c500;i++){
            int c100 = Math.min(B,(X-500*i)/100);
            for(int j=0;j<=c100;j++){
                int remain = X-i*500-j*100;
                if(remain/50<=C) ans += 1;
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  string s;
  string m[h][w];
  for (int i=0; i<h; i++){
    cin >> s;
    for (int j=0; j<w; j++){
      m[i][j] = s[j];
    }
  }
  
  
  //if(m[0][2] == "#"){cout << "te";}
  int c = 0;
  int res = 0;
  for (int tmp = 0; tmp < (1 << h); tmp++) {
  // nはビット数。12個に対して2^12通り試す場合、n=12を設定
    for (int tm = 0; tm < (1 << w); tm++) {
      c = 0;
      for (int i = 0; i < h; i++) {
        if (tmp & (1<<i)){
          for (int j = 0; j < w; j++) {
            //cout << m[i][w] << endl;
            if (tm & (1<<j)){
              if(m[i][j] == "#"){
                c++;
              }
            }
          }
        }
      }
      //cout << c << endl;
      if(c == k){
        //cout << tmp << " " << tm <<endl;
        res ++ ;
      }
     
    }
  }
  
  cout << res;
}


Measured memory_bytes: 3600
using System;
using System.IO;
using System.Linq;

namespace AGC013
{
    class C
    {
        static void Main(string[] args)
        {
            var NLT = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = NLT[0];
            var L = NLT[1];
            var T = NLT[2];
            var AntPos = new int[N];
            var StdDir = 1;
            var XW = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var X = XW[0];
            var W = XW[1];
            AntPos[0] = X;
            StdDir = W == 1 ? 1 : -1;
            var collision = 0;
            for (int i = 1; i < AntPos.Length; i++)
            {
                XW = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                X = XW[0];
                W = XW[1] == 1 ? 1 : -1;
                AntPos[i] = ((W == 1 ? X + T : X - T) % L + L) % L;
                if (W != StdDir)
                {
                    var diff = Math.Abs(X - AntPos[0]);
                    diff = StdDir == 1 ? diff : L - diff;
                    collision += (2 * T - diff) >= 0 ? (2 * T - diff) / L + 1 : 0;
                }
            }
            AntPos[0] = ((StdDir == 1 ? AntPos[0] + T : AntPos[0] - T) % L + L) % L;
            var StdPos = AntPos[0];

            Array.Sort(AntPos);

            var offset = BinarySearch(AntPos, StdPos);
            if (StdDir == -1 && AntPos[(offset - 1 + N) % N] == StdPos) offset--;

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            for (int i = 0; i < AntPos.Length; i++)
            {
                var index = ((i + offset - StdDir * collision) % N + N) % N;
                Console.WriteLine(AntPos[index]);
            }

            Console.Out.Flush();
        }

        public static int BinarySearch<T>(T[] array, T target) where T : IComparable<T>
        {
            int min = 0;
            int max = array.Length - 1;

            while (true)
            {
                if (max < min) return -1;
                int mid = min + (max - min) / 2;
                switch (target.CompareTo(array[mid]))
                {
                    case -1:
                        max = mid - 1;
                        break;
                    case 1:
                        min = mid + 1;
                        break;
                    case 0:
                        return mid;
                }
            }
        }
    }
}


Measured memory_bytes: 18360
#include <bits/stdc++.h>
//#include "Local_Debug.h"
using namespace std;
#define Endl endl
#define debug(x) cout << #x << " = " << (x) << endl
typedef long long ll;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e6 + 5;
ll x, y;

ll fact(ll n, ll p)
{
	ll ret = 1;
	for (ll i = 1; i <= n; ++i)
		ret = ret * i % p;
	return ret;
}
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d)
{
	if (!b)
		d = a, x = 1, y = 0;
	else
		ex_gcd(b, a % b, y, x, d), y -= x * (a / b);
}
ll inv(ll a, ll p)
{
	ll d, x, y;
	ex_gcd(a, p, x, y, d);
	return d == 1 ? (x % p + p) % p : -1;
}
ll comb(ll n, ll m, ll p)
{
	if (m < 0 || m > n)
		return 0;
	return fact(n, p) * inv(fact(m, p), p) % p * inv(fact(n - m, p), p) % p;
}
ll Lucas(ll n, ll m, ll p)
{
	return m ? Lucas(n / p, m / p, p) * comb(n%p, m%p, p) % p : 1;
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	while (cin >> x >> y)
	{
		ll sum = x + y;
		if (sum % 3 == 0)
			cout << Lucas(sum / 3, x - sum / 3, MOD) << endl;
		else
			cout << 0 << endl;
	}
}
/*
3 3

2 2

999999 999999
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    string s; cin >> s;
    int num1,num2;
    rep(i,s.size()){
        if(s[i]=='A'){
            num1 = i;
            break;
        }
    }
    for(int i = s.size()-1; i >= 0; i--){
        if(s[i]=='Z'){
            num2 = s.size()-i-1;
            break;
        }
    }
    cout << s.size()-num1-num2 << endl;

    return 0;
}

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

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

	int N = S.size();
	vector<int> L( N );
	for( int i = 0; i < N; i++ ) {
		if( S[i] == 'L' ) {
			L[i] = 1;
		}
	}
	for( int i = 0; i < N - 1; i++ ) {
		if( S[i] == 'L' && S[i + 1] == 'L' ) {
			L[i + 1] += L[i];
		}
	}
	vector<int> R( N );
	for( int i = 0; i < N; i++ ) {
		if( S[i] == 'R' ) {
			R[i] = 1;
		}
	}
	for( int i = N - 1; i > 0; i-- ) {
		if( S[i] == 'R' && S[i - 1] == 'R' ) {
			R[i - 1] += R[i];
		}
	}
	vector<int> a( N, 1 );
	for( int i = 0; i < N; i++ ) {
		int k;
		if( S[i] == 'L' ) {
			int n = L[i];
			int p = 0;
			if( n % 2 ) p = 1;
			k = i - n + p;
		}
		else {
			int n = R[i];
			int p = 0;
			if( n % 2 ) p = 1;
			k = i + n - p;
		}
		a[k]++;
		a[i]--;
	}

	for( int i = 0; i < N; i++ ) {
		if( i ) cout << " ";
		cout << a[i];
	}
	cout << endl;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

string code(string s) {
  string res = "";
  res.pb(s[0]);
  REP(i, SZ(s)-1) {
    if(s[i] == 'a' || s[i] == 'i' || s[i] == 'u' || s[i] == 'e' || s[i] == 'o') {
      res.pb(s[i+1]);
    }
  }
  return res;
}

bool bs(int now, const vector<string> &full) {
  map<string, int> m;
  int n = SZ(full);
  bool ok = true;
  REP(i, n) {
    if(m[full[i].substr(0, now)]++ >= 1) {
      ok = false;
      break;
    }
  }
  return ok;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    vector<string> full(n);
    int ma = 0;
    REP(i, n) {
      string tmp; cin >> tmp;
      full[i] = code(tmp);
      ma = max(ma, SZ(full[i]));
    }
    // printv(full);

    int l = 0, r = ma+1;
    while(r-l > 1) {
      // cout << l << ":" << r << endl;
      int mid = (l+r)/2 + (l+r)%2;
      if(bs(mid, full)) {
        r = mid;
      } else {
        l = mid;
      }
    }
    cout << (r <= ma ? r : -1) << endl;
  }
}




Measured memory_bytes: 3180
import java.util.Scanner;

public class Main {

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

		double base = sc.nextDouble();
		double side = sc.nextDouble();
		double corner = sc.nextDouble();

		System.out.println(AreaCalculation(base, side,corner));
		System.out.println(CircumferenceCalculation(base, side, corner));
		System.out.println(HeightCalculation(base, side, corner));

	}

	static double AreaCalculation(double a, double b,double corner) {
		return a * (b * Math.sin(Math.toRadians(corner))) / 2;
	}

	static double CircumferenceCalculation(double a, double b, double corner) {
		double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - (2 * a * b * Math.cos(Math.toRadians(corner))));
		return a + b + c;
	}

	static double HeightCalculation(double a, double b, double corner) {
		return AreaCalculation(a, b, corner) * 2 / a;
	}

}



Measured memory_bytes: 27860
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n,  const Monoid &M1) :  M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int i;
	char s[10];
	cin >> s;
	for (i = 0; i < 3; i++) {
		if (s[i] == s[i + 1]) {
			cout << "Bad" << endl;
			return 0;
		}
	}
	cout << "Good" << endl;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	vector<int > v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}
	int now = 0;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (i != N - 1) {
			if (v[i] >= v[i + 1]) {
				now++;
			}
			else {
				ans = max(ans, now);
				now = 0;
			}
		}
	}
	cout << max(ans, now) << endl;

	return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
# 1. 素因数分解して公約数を作成(A,B共に)
# 2. 

from collections import Counter # N : 素因数分解


def calc_prime_factor(N):
    prime_factor = []
    for i in range(2, int(N**0.5)+1):
        while N % i == 0:
            prime_factor.append(i)
            N /= i
    if N > 1:
        prime_factor.append(N)
    return prime_factor


A, B = [int(s) for s in input().split()]

prime_A = calc_prime_factor(A)
prime_B = calc_prime_factor(B)

print(len(list(set(Counter(prime_A).keys()) & set(Counter(prime_B).keys()))) + 1)

Measured memory_bytes: 3444
#include <bits/stdc++.h>//方針：異なる物の数＝＝N-同じ数
using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  for(int i=0;i<N;i++){
    cin >> d[i];
  }
//sortしたい
  for(int s=0;s<N;s++){
    for(int t=s+1;t<N;t++){
      if(d[t]<d[s]){
      	int k = d[s];
          d[s]= d[t];
          d[t]= k;
      }
    }
  }//小さい順にソートできた
  int k = 0;
  for(int s=0;s<N-1;s++){
    if(d[s]==d[s+1])
      k++;
  }
  
	cout << N-k << endl;
        
}


Measured memory_bytes: 256
import sys
from collections import Counter

inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

s = input()

if "N" in s and "S" in s and "E" in s and "W" in s:
    print("Yes")
    exit()

if ("N" in s and "S" in s) and ("E" not in s and "W" not in s):
    print("Yes")
    exit()

if ("E" in s and "W" in s) and ("N" not in s and "S" not in s):
    print("Yes")
    exit()

print("No")

Measured memory_bytes: 83116
#include<stdio.h>
#define MAX 250
#define MIN -2147483648
struct node{
  int key,parent,left,right;
};
struct node A[MAX*2+2];
int parent(int);
int left(int);
int right(int);

int main(){
  int i,n;
  for(i=0;i<=MAX*2+1;i++){
    A[i].key=MIN;
      }
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i].key);
  }
  for(i=1;i<=n;i++){
    A[i].parent = parent(i);
    A[i].left = left(i);
    A[i].right = right(i);
  }
  for(i=1;i<=n;i++){
    printf("node %d: ",i);
    printf("key = %d, ",A[i].key);
    if(i!=1) printf("parent key = %d, ",A[i].parent);
    if(A[i].left!=MIN) printf("left key = %d, ",A[i].left);
    if(A[i].right!=MIN) printf("right key = %d, ",A[i].right);
    printf("\n");
  }
  
  return 0;
}
int parent(int i){
  return A[i/2].key;
}
int left(int i){
  return A[2*i].key;
}
int right(int i){
  return A[2*i+1].key;
}



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

using namespace std;

int main()
{
    int i,num=0;
    string S;
    cin>>S;
    for(i=0; i<3; i++)
        if(S[i]=='R')
            num++;
    if(num==2)
    {
        if(S[1]=='R')
            cout<<2<<endl;
        else
            cout<<1<<endl;
    }
    else
        cout <<num<< endl;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    char ch;
    int x=0,y=97;
    char z;
    int w[25]={0};
    
    while( scanf("%c", &ch) != EOF ){
        
        if('A'<=ch && ch<='Z'){
            ch=ch+32;
        }
        
        if('a'<=ch && ch<='z'){
            w[ch-97]++;
        }
        
        x++;
    }
    
    for(y=97;y<=122;y++){
        z=y;
        printf("%c : %d\n",z,w[y-97]);
    }
    
    
    return 0;
}



Measured memory_bytes: 2104
N = int(input()) #<=4000
S = list(input())

R_index = list()
G_index = list()
B_index = list()

for i in range(N):
    if S[i] == "R":
        R_index.append(i+1)
    elif S[i] == "G":
        G_index.append(i+1)
    if S[i] == "B":
        B_index.append(i+1)

#組 (i, j, k) (1≤i<j<k≤N) の数を求めてください。
#Si≠Sj かつ Si≠Sk かつ Sj≠Sk である
#j−i≠k−jの条件下で組み合わせる
#j−i=k−j
#↓
#2j−i=k ≡ 2j−k=i  ≡ (i+k)/2 = j はNGということ。

ans = len(R_index)*len(G_index)*len(B_index) #まず全通りを計算
B_set = set(B_index)

#NG分を除去する
for R in R_index:
    for G in G_index:
        #R,G,Bのi,j,kへのあてはめ方は6通り。大小関係にも注意
        #(R,G,B),(R,B,G),(G,B,R),(G,R,B),(B,R,G),(B,G,R)
        if (R+G)/2 in B_set:
            ans -= 1
        if 2*G-R in B_set:
            ans -= 1
        if  2*R-G in B_set:
            ans -= 1
        
print(ans)

Measured memory_bytes: 9264
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r;
	cin >> r;
	int ans = 3 * r * r;
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

const int MAX = 2e5+10;

int N;
int A[MAX], B[MAX];

ll solve() {
    sort(A, A+N);
    sort(B, B+N);
    if (N&1) return B[N/2] - A[N/2] + 1;
    return (B[N/2-1] + B[N/2]) - (A[N/2-1] + A[N/2]) + 1;
}

int main() {
    cout << fixed << setprecision(15);
    cin >> N;
    REP (i, N) cin >> A[i] >> B[i];
    cout << solve() << endl;
}

Measured memory_bytes: 5208