akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
//#define P pair<int, int>

using namespace std;
using ll = __int64_t;

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

bool isPrime(int n){
  if(n < 2) return false;
  for(int i = 2; i*i <= n; i++){
    if(n%i == 0) return false;
  }
  return true;
}

void solve(){
  int n;
  cin >> n;

  for(int i = 31; i <= 55555; i += 30){
    if(isPrime(i)){
      cout << i << " ";
      n--;
    }
    if(n == 0){
      break;
    }
  }
  cout << endl;
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static  void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextInt();
        long m = scanner.nextInt();

        long min = Math.min(n,m);
        long max = Math.max(n,m);
        if(min == 1){
            if(max == 1){
                System.out.println(1);
            }else if(max == 2){
                System.out.println(0);
            }else {
                System.out.println(max-2);
            }
        }else if(min == 2){
            System.out.println(0);
        }else {
            System.out.println((max-2)*(min-2));
        }
    }
}
		

Measured memory_bytes: 21716
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<62;
const double pi=acos(-1);
const long double eps=1e-7;
const ll mod=1e6+3;
const int dx[8]={0,1,0,-1,-1,-1,1,1},dy[8]={1,0,-1,0,-1,1,-1,1};

string s,t;

int main(){
	cin>>s>>t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());
	if(s<t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, c;
  cin >> a >> b >> c;
  if(c - a - b > 0){
    if(4 * a * b < (c - a - b) * (c - a - b)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	long long n, a, b;
	cin >> n >> a >> b;
	if (n == 1) {
		if (a != b) {
			cout << "0" << endl;
			return 0;
		}
	}
	if (a == b) {
		cout << "1" << endl;
		return 0;
	}
	if (a > b) {
		cout << "0" << endl;
		return 0;
	}
	else {
		cout << (n - 2) * b - (n - 2) * a + 1 << endl;
		return 0;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll solve(ll x) {

    for (ll i = std::sqrt(x); i > 1; --i)
    {
        ll y = x / i;

        if (i * y == x)
            return i;
    }

    return -1;
}

int main() {
    fast_io();

    ll x = fetch<ll>();
    ll y = solve(x);

    if (y == -1)
        std::cout << x - 1 << std::endl;
    else
        std::cout << y - 1 + (x / y) - 1 << std::endl;

    return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        int a=sc.nextInt();
        a%=10;
        if(a==3)
            System.out.println("bon");
        else if(a==0||a==1||a==6||a==8)
            System.out.println("pon");
        else System.out.println("hon");



    }
}


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

int main() {
  int N;
  cin>>N;
  while(1==1){
    int a=0;
    for(int i=2;i<=sqrt(N);i++){
      if(N%i==0){
        a++;
        break;
      }
    }
    if(a==1){
      N++;
      continue;
    }
    else{
      cout<<N<<endl;
      break;
    }
  }
}


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

int main(){
  int d,g,kekka = 1000000;
  cin >> d >> g;
  int p[d],c[d];
  for(int i = 0;i < d;i++){
    cin >> p[i] >> c[i];
  }
  for(int i = 1;i < 1<<d;i++){
    int rest = g,cur = 0;
    vector<int> nokori(d);
    for(int j = 0;j < d;j++){
      nokori.at(j) = 1;
      if((1 & i>>j) == 1){
        rest -= 100*(j+1)*p[j] + c[j];
        cur += p[j];
        nokori.at(j) = 0;
      }
    }
    //cout << rest << endl;
    int high = 0;
    for(int j = d-1;j >= 0;j--){
      if(nokori.at(j) == 1){
        high = j;
        break;
      }
    }
    if(rest <= 100*(high+1)*(p[high]-1) && rest > 0){
      for(int j = 1;j > 0;j++){
        if(rest <= 100*(high+1)*j){
          cur += j;
          break;
        }
      }
    }
    if(rest <= 100*(high+1)*(p[high]-1)){
      kekka = min(kekka,cur);
    }
    //cout << kekka << " " << cur << endl;
  }
  int o;
  if(g <= 100*d*(p[d-1]-1)){
    for(int j = 1;j > 0;j++){
       if(g <= 100*d*j){
          o = j;
          break;
       }
    }
    //cout << o << endl;
    kekka = min(kekka,o);
  }
  cout << kekka << endl;
}

Measured memory_bytes: 256
use strict;
use utf8;
use warnings;

sub max{
    my($a, $b) = @_;
    if ($a > $b) {$a} else {$b}
}

chomp(my $n = <STDIN>);
my $i = 1;
my $min = 2**31-1;
while ($i <= sqrt($n)){
    if ($n%$i == 0){
        my $tmp_min = &max(length $i, length $n/$i);
        if ($tmp_min < $min){$min = $tmp_min}
    }
    $i++;
}
print "$min\n";

Measured memory_bytes: 768
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
a = list(map(int, input().split()))
left = defaultdict(int)

for i in range(N-1, -1, -1):
    left[a[i]] = i

l = list(set(a))
l.sort(reverse=True)
ans = [0]*N
now = left[max(a)]
cnt = Counter(a)

for i in range(len(l)-1):
    ans[now] += (l[i]-l[i+1])*cnt[l[i]]
    cnt[l[i+1]] += cnt[l[i]]
    now = min(now, left[l[i+1]])

ans[now] += l[-1]*cnt[l[-1]]

for ans_i in ans:
    print(ans_i)

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

#define ll long long
#define llu unsigned long long
#define ld long double
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define iter :: iterator
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'
#define all(x) x.begin(),x.end()
#define foreach(it,v) for( __typeof((v).begin())it = (v).begin() ; it != (v).end() ; it++ )
#define present(v,x) (v).find(x) != (v).end()
#define cpresent(v,x) (find(all(v),x) != (v).end())
#define mset(x,v) memset(x, v, sizeof(x))
#define sz(x) (int)x.size()
#define shout()  {cout << "I'm Here...!!!" << endl;}
#define dbg(x) { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y) { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }

inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int addmod(int a, int val, int p = MOD) {{if ((a = (a + val)) >= p) a -= p;} return a;}
inline int submod(int a, int val, int p = MOD) {{if ((a = (a - val)) < 0) a += p;}return a;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

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

	int n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	for(int i=1; i<=n; i++)
		cin >> a[i];

	int dp[n+1][k+1], pref[n+1][k+1];
	mset(dp, 0);
	mset(pref, 0);
	dp[0][0] = 1;
	for(int i=0; i<=k; i++)
		pref[0][i] = 1;

	for(int i=1; i<=n; i++)
		for(int j=0; j<=k; j++){
			dp[i][j] = submod(pref[i-1][j], (j-a[i]-1>=0?pref[i-1][j-(a[i]+1)]:0));
			pref[i][j] = addmod((j-1>=0?pref[i][j-1]:0), dp[i][j]);
		}

	cout << dp[n][k] << endl;

	return 0;
}

Measured memory_bytes: 79104
#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)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int x,n;
  cin>>x>>n;
  vector<int>a(109);
  rep(i,n){
    int p;
    cin>>p;
    a[p]=true;
  }
  int d=INF;
  int ans;
  for(int i=0;i<106;i++){
    if(a[i]==false){
      if(d>abs(i-x)){
        d=abs(i-x);
        ans=i;
      }
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man

int main()
{
    ll a,b;
    cin >> a >> b;
    if(abs(a-b)<2)
        printf("Brown");
    else
        printf("Alice");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,x;
    cin >> n >> x;
    int L[n];
    REP(i,n){
        cin >> L[i];
    }

    int tmp = 0;
    int cnt = 1;
    REP(i,n){
        tmp += L[i];
        if(tmp <= x) cnt ++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
S = input()
K = int(input())

X = []
b = S[0]
cnt = 1
for i in range(1, len(S)):
    s = S[i]
    if b == s:
        cnt += 1
    else:
        X.append([b, cnt])
        cnt = 1
        b = s
X.append([b, cnt])

if len(X) == 1:
    print(X[0][1] * K // 2)
elif X[0][0] != X[-1][0]:
    print(sum(x[1] // 2 for x in X) * K)
else:
    s = X.pop(0)
    e = X.pop()
    result = sum(x[1] // 2 for x in X) * K + s[1] // 2 + e[1] // 2 + ((s[1] + e[1]) // 2) * (K - 1)
    print(result)



Measured memory_bytes: 3064
# F - Select Half
N = int(input())
A = list(map(int,input().split()))

if N%2==0:
    rec = [[0]*N for _ in range(2)]
    rec[0][0] = A[0]
    rec[1][1] = A[1]
    for i in range(2,N):
        rec[0][i] = rec[0][i-2]+A[i]
        rec[1][i] = max(rec[0][i-3],rec[1][i-2])+A[i]
    ans = max(rec[0][N-2],rec[1][N-1])
else:
    rec = [[0]*N for _ in range(3)]
    rec[0][0] = A[0]
    rec[1][1] = A[1]
    rec[0][2] = A[0]+A[2]
    rec[2][2] = A[2]
    for i in range(3,N):
        rec[0][i] = rec[0][i-2]+A[i]
        rec[1][i] = max(rec[0][i-3],rec[1][i-2])+A[i]
        rec[2][i] = max(rec[0][i-4],rec[1][i-3],rec[2][i-2])+A[i]
    ans = max(rec[0][N-3],rec[1][N-2],rec[2][N-1])
    
print(ans)

Measured memory_bytes: 52136
#include <stdio.h>
#include <string.h>

int main(){
	int lg;
	scanf ("%d", &lg);
	char word[lg+1];
	int st1 = 0;
	int st2 =lg/2;
	int wall = st2-1;
	scanf ("%s", word);
	
	if (lg % 2 != 0){
		printf ("No\n");
		return 0;
	}
	
	for (int i=0; i<=wall; i++){
		if (word[st1+i] == word[st2+i]){
			continue;
		}
		else {
			printf ("No\n");
			return 0;
		}
	}
	
	printf ("Yes\n");
return 0;
}

Measured memory_bytes: 1632
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const int MAX_N = 100010;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    vector<int> prime(MAX_N, 1);
    prime[0] = prime[1] = 0;
    for(int i = 2; i * i < MAX_N; i++)
    {
        for(int j = 2 * i; j < MAX_N; j += i)
        {
            prime[j] = 0;
        }
    }
    while(cin >> n)
    {
        for(int i = n - 1; ; i--)
        {
            if(prime[i] == 0) continue;
            cout << i << " ";
            break;
        }
        for(int i = n + 1; ; i++)
        {
            if(prime[i] == 0) continue;
            cout << i << endl;
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 3176
//usr/bin/env node --harmony $0 $@;exit
var main=function(){
	var arg=readline().split(' ').map(Number);
	var y=arg[0],x=arg[1];
	var m=Array(y);
	for(var j=0;j<y;j++){
		arg=readline().split(' ').map(Number);
		r=0;
		m[j]=Array(x);
		for(var i=0;i<x;m[j][i]=r,i++){
			r=arg[i]==0?r+1:0;
		}
	}
	var r=0;
	for(var i=0;i<x;i++)for(var j=0;j<y;j++)for(var M=x,k=j;k<y;k++){
		if(M>m[k][i])M=m[k][i];
		var z=k-j+1;
		if(M<z)break;
		if(r<z)r=z;
	}
	print(r*r);
}

/// IO ///
if(typeof process!=='undefined'){
	//node.js
	var print=function(x){
		console.log(x);
	}
	var readline=(function(){
		var T=[],cnt=0;
		var stdin = process.openStdin();
		stdin.setEncoding('utf8');

		var input_fragment="";
		stdin.on('data', function(input) {
			var ref=(input_fragment+input).split("\n");
			input_fragment=ref.pop();
			for(var i=0;i<ref.length;i++){
				if(ref[i]=='')continue;
				T.push(ref[i]);
			}
		});
		stdin.on('end', function(z) {
			if(input_fragment){
				var ref=(input_fragment+"\n").split("\n");
				input_fragment=ref.pop();
				for(var i=0;i<ref.length;i++){
					if(ref[i]=='')continue;
					T.push(ref[i]);
				}
			}
			main();
		});

		return function(){
			if(T.length<=cnt)return null;
			return T[cnt++];
		};
	})();
}else{
	//v8
	main();
}

Measured memory_bytes: 55656
#include <bits/stdc++.h>
#define FOR(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define FORUL(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#define FORULE(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define FOREACH(it, X) for(__typeof((X).begin()) it = (X).begin(); it != (X).end(); it++)
#if defined(_MSC_VER) || __cplusplus > 199711L
#define AUTOVAR(newvar,v) auto newvar = (v)
#else
#define AUTOVAR(newvar,v) __typeof(newvar) r = (v)
#endif
#define PB(x) push_back(x)
#define MP(x,y) make_pair((x),(y))
#define MEMSET(m,v) memset(m,v,sizeof(m))

typedef long long				 ll;
typedef unsigned long long		ull;

#define DEBUG 1

#if DEBUG
#define DOUT cout<<"["<<__LINE__<<"]:"
#else
#define DOUT 0 && cout
#endif

using namespace std;


int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false);

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

	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文
int main(){
	string a, b, c;
	cin >> a >> b >> c;
	bool ans = true;
	if (b.at(0) != a.at(a.size() - 1)) ans = false;
	if (c.at(0) != b.at(b.size() - 1)) ans = false;
	ansYES(ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,k,a[20001],i,j,mx,mi;
	long long dp[20001];
	scanf("%d %d %d",&n,&m,&k);
	for(i=1;i<=n;i++)	scanf("%d",&a[i]);
	for(i=0;i<=n;i++)	dp[i]=(long long)i*k;
	for(i=0;i<n;i++)	{
//		for(j=0;j<=n;j++)	printf("%lld ",dp[j]);	printf("\n");
		mx=a[i+1];	mi=a[i+1];
		for(j=1;j<=m;j++)	{
			if(j+i>n)	break;
			mx=max(mx,a[i+j]);
			mi=min(mi,a[i+j]);
			dp[i+j]=min(dp[i+j],dp[i]+k+(long long)j*(mx-mi));
		}
	}
	printf("%lld\n",dp[n]);
	return 0;
}


Measured memory_bytes: 2984
# sys.stdin.readline
import re
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        print('YES' if re.match('^(dream(er)?|eraser?)*$', S) else 'NO')


# Run main
if __name__ == '__main__':
    AtCoder().main()

Measured memory_bytes: 44124
N = int(input())

A = []
B = []
C = []
D = []

for i in range(1, 30001):
    if i % 6 == 0:
        A.append(i)
    elif i % 6 == 2:
        B.append(i)
    elif i % 6 == 3:
        C.append(i)
    elif i % 6 == 4:
        D.append(i)
    else:
        pass

if N == 3:
    res = [2, 5, 63]
elif N == 4:
    res = [2, 4, 3, 9]
elif N == 5:
    res = [2, 4, 3, 9, 6]
elif N <= 15000:
    res = A[:N % 6] + B[:N // 6 * 2] + C[:N // 6 * 2] + D[:N // 6 * 2]
else:
    res = A[:N - 15000] + B + C + D

print(*res)

Measured memory_bytes: 4848
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
typedef pair<int, int> PII;
const int mod = 1e9 + 7;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int ll;
ll powmod(ll a, ll b) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}
int nxt() {
    int x;
    scanf("%d", &x);
    return x;
}
void add_self(int &a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}

void sub_self(int &a, int b) {
    a -= b;
    if (a < 0) a += mod;
}

int main() {
    int n = nxt(), k = nxt();
    // dp[i] - the number of ways such that we used i candies so far
    VI dp(k + 1);
    dp[0] = 1;
    for (int child = 0; child < n; child++) {
        int up_to = nxt();
        VI fake(k + 1);
        for (int used = k; used >= 0; used--) {
            int tmp = dp[used];
            int L = used + 1;
            int R = used + min(up_to, k - used);
            if (L <= R) {
                add_self(fake[L], tmp);
                if (R + 1 <= k)
                    sub_self(fake[R + 1], tmp);
                // for (int i = L; i <= R; ++i)
                // add_self(dp[i], tmp);
            }
        }
        int prefix_sum = 0;
        REP(i, k + 1) {
            add_self(prefix_sum, fake[i]);
            add_self(dp[i], prefix_sum);
        }
    }
    printf("%d\n", dp[k]);
    return 0;
}


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

typedef vector<int> vi;

int main()
{
	int n, w, i, e, _min, it;
	scanf("%d", &n);
	vi nums(n + 1);
	for (i = 1; i <= n; i++) {
		scanf("%d ", &e);
		nums[i] = nums[i - 1] + e;
	}
	it = lower_bound(nums.begin(), nums.end(), nums[n] / 2) - nums.begin();
	_min = abs((nums[n] - nums[it]) - nums[it]);
	if (it + 1 <= n)
		_min = min(_min, abs((nums[n] - nums[it + 1]) - nums[it + 1]));
	if (it - 1 >= 0)
		_min = min(_min, abs((nums[n] - nums[it - 1]) - nums[it - 1]));
	printf("%d\n", _min);
	return 0;
}

Measured memory_bytes: 256
mod = 10 ** 9 + 7

n, k = gets.to_s.split.map{|e|e.to_i}

ans = (k..n+1).map{|i| i * (n + n - i + 1) / 2 - i * ( i - 1 ) / 2 + 1 }.sum % mod

puts ans

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

long long max(long long a, long long b){
    if(a > b){
        return a;
    } else {
        return b;
    }
}

long long min(long long a, long long b){
    if(a < b){
        return a;
    } else {
        return b;
    }
}

int main(){
    long long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long ans = 1000000000;
    for(long long z = 0; z <= max(x, y); z++){
        ans = min(ans, z*2*c + max(0, x-z)*a + max(0, y-z)*b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,i;
    scanf("%d%d",&a,&b);
    i=a*b;
    if(i%2==0)
    {
        printf("Even\n");
    }
    else
    {
        printf("Odd\n");
    }
    return 0;
}


Measured memory_bytes: 1616
#include <stdio.h>
int main(void)
{
	int a, b, d, r;
	double i, j, f;

	scanf("%d %d", &a, &b);
	if ((1 <= a) && (1 <= b))
	{
		d = a / b;
		r = a % b;
		i = a;
		j = b;
		f = i / j;
		printf("%d %d %.5f\n",d,r,f);
	}
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
using namespace std;
int main(void){
  int n,t,sum;
  scanf("%d", &n);
  t = n;
  sum = 0;
  while(t){
    sum += t%10;
    t /= 10;
  }
  puts(n%sum==0?"Yes":"No");
  return 0;
}

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

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

const int mod = 1e9+7;

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

    int n;
    cin >> n;
    vector<ll> v(n);
    REP(i, n) cin >> v[i];

    ll ans = 0;
    REP(i, 60) {
        ll a = 0;
        REP(j, n) {
            if(v[j] >> i & 1) { // 1を桁上げするのではなく，変数を右シフトして1桁目で比べる
                a++;
            }
        }
        ll b = (n - a) * a;
        REP(j, i) b = b * 2 % mod; 
        ans += b;
        ans %= mod;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 2560
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * File:   main.cpp
 * Author: shrif
 *
 * Created on January 20, 2017, 8:32 AM
 */

//============================================================================
// Name        : recursion.cpp
// Author      : Sherif Embarak
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;

int n, s;
int table[50010];

int main() {

    cin >> s>>n;
    vector<int>v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];

    table[0] = 0;
    for (int i = 1; i <= s; i++)
        table[i] = INT_MAX;

    for (int i = 0; i < n; i++) {
        for (int j = 1; j <= s; j++) {
            if (j >= v[i])
                if (table[j - v[i]] != INT_MAX)
                    table[j] = min(table[j], table[j - v[i]] + 1);
        }
    }
    cout << table[s] << endl;
    return 0;
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    
    if (A == B) {
        if(A == C) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    } else if (B == C) {
        cout << "Yes" << endl;
    } else if (A == C) {
        cout << "Yes" << endl;
    } else {
        cout << "No";
    }
}


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

int main()
{
    string s;
    cin >> s;
    int i;
    string t;
    for(i = 0;i < s.size();++i){
        if(s.at(i) == '0'){
            t.push_back('0');
        }else if(s.at(i) == '1'){
            t.push_back('1');
        }else if(s.at(i) == 'B'){
            if(t.size() == 0){
                continue;
            }else{
                t.erase(t.end()-1);
            }
        }
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	s.pop_back();
	while (1) {
		if (s.size() % 2) {
			s.pop_back();
		} else {
			if (s.substr(0, s.size() / 2) == s.substr(s.size() / 2, s.size())) {
				cout << s.size() << endl;
				return 0;
			} else {
				s.pop_back();
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
    int n,i,flag=0;
    char s;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%*c");
        scanf("%c", &s);
        if (s == 'Y')
            flag = 1;
    }
    if (flag == 0)
        printf("Three");
    else
        printf("Four");
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstring>
const int N=5005;
int n,q;

template <class T> inline void apn(T &x,const T y){
	if(x>y) x=y;
}

inline int nxi(){
	int x=0;
	char c;
	while((c=getchar())>'9'||c<'0');
	while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
	return x;
}

namespace G{
	int cnt,res,ans,fir[N],dep[N];
	bool vis[N];
	struct edge{
		int to,nx;
	}eg[N];

	inline void add(const int a,const int b){
		eg[++cnt]=(edge){b,fir[a]};
		fir[a]=cnt;
	}
	inline void init(){
		res=0;
		memset(vis,0,sizeof(vis));
		memset(dep,1,sizeof(dep));
	}

	inline void dfs(const int x){
		vis[x]=1;
		res+=dep[x]>q>>1;
		for(int i=fir[x];i;i=eg[i].nx){
			const int y=eg[i].to;
			if(!vis[y]){
				apn(dep[y],dep[x]+1);
				dfs(y);
			}
		}
	}
	inline void solve(){
		ans=1e9;
		for(int i=1;i<=n;++i){
			init();
			dep[i]=0;
			dfs(i);
			apn(ans,res);
		}
		++q;
		for(int i=1;i<=n;++i){
			for(int j=fir[i];j;j=eg[j].nx){
				const int k=eg[j].to;
				if(i<k){
					init();
					dep[i]=dep[k]=1;
					dfs(i);
					apn(G::ans,G::res);
				}
			}
		}
	}
}

int main(){
#ifndef ONLINE_JUDGE
//	freopen("c.in","r",stdin);
#endif
	n=nxi(),q=nxi();
	for(int i=1;i<n;++i){
		const int a=nxi(),b=nxi();
		G::add(a,b);
		G::add(b,a);
	}
	G::solve();
	printf("%d\n",G::ans);
	return 0;
}

Measured memory_bytes: 384
import heapq

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

    H = []
    for a in A:
        H.append(-a)
    heapq.heapify(H)

    for _ in range(M):
        a = heapq.heappop(H)
        a = -1 * a
        a //= 2
        heapq.heappush(H,-a)

    print(-sum(H))
if __name__ == '__main__':
    main()

Measured memory_bytes: 14180
#include "bits/stdc++.h"
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define int long long int
#define tc int t; cin>>t; while(t--)
#define fora(i,n) for(int i=0;i<n;i++)
#define forb(i,a,n) for(int i=a;i<n;i++)
#define mod 1000000007

template<class T> T power(T N,T P){ return (P==0)?  1: N*power(N,P-1);}

int32_t main()
{
    fastio

 	int n,m,k;
 	cin>>n>>m>>k;
 	int k1=k;
 	int cpy=k;
 	int a[n],b[m];
 	fora(i,n) cin>>a[i];
 	fora(i,m) cin>>b[i];
 	int l1=0,l2=0;
 	int prefa[n],prefb[m];
 	prefa[0]=a[0];
 	prefb[0]=b[0];
 	for(int i=1;i<n;i++)
 		prefa[i]=prefa[i-1]+a[i];
 	for(int i=1;i<m;i++) prefb[i]=prefb[i-1]+b[i];
 		int cnt=0,cnt1=0;
 		int ptr=m-1,ptr1=n-1;
 		fora(i,n) {
 			if(prefa[i]<=k) {
 				int diff=k-prefa[i];
 				int xx=i+1;
 				while(ptr>=0) {
 					if(prefb[ptr]<=diff)
 					{
 						xx+=ptr+1;
 						break;
 					}
 					else ptr--;
 				}
 				cnt=max(cnt,xx);

 			}


 		}
 		// cout<<cnt<<"\n";
 		fora(i,m) {
 			if(prefb[i]<=k) {
 				int diff=k-prefb[i];
 				int xx=i+1;
 				while(ptr1>=0) {
 					if(prefa[ptr1]<=diff)
 					{
 						xx+=ptr1+1;
 						break;
 					}
 					else ptr1--;
 				}
 				// if(xx==4)
 					// cout<<"idx "<<prefb[i]<<" "<<i<<"\n";
 				cnt=max(cnt,xx);

 			}


 		}

		cout<<cnt;

    return 0;


}

Measured memory_bytes: 9892
fun main() {
    val n = readLine()?.toInt() ?: return
    when (n % 10) {
        2, 4, 5, 7, 9 -> {
            println("hon")
        }
        0, 1, 6, 8 -> {
            println("pon")
        }
        3 -> {
            println("bon")
        }
    }
}


Measured memory_bytes: 34324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    IOS;
    int n;
    cin >> n;
    vector<bool> s(1000005, 0);
    bool pairwise = 1;
    int total = 0;
    rep(i, 0, n)
    {
        int t;
        cin >> t;
        if (s[t] && t != 1)
            pairwise = 0;
        else if (!s[t])
        {
            s[t] = 1;
            total++;
        }
    }
    vector<bool> checked(1000005, 0);
    int count = 0;
    for (int i = 2; i <= 1000000; i++)
    {
        if (checked[i])
            continue;
        if (total == count)
            break;
        count = 0;
        for (int j = 1; i * j <= 1000000; j++)
        {
            checked[i * j] = 1;
            if (s[i * j] == 1)
                count++;
        }
        if (count >= 2)
            pairwise = 0;
    }
    if (pairwise)
        cout << "pairwise coprime" << endl;
    else if (count == total)
        cout << "not coprime" << endl;
    else
        cout << "setwise coprime" << endl;
}


Measured memory_bytes: 3764
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>

using namespace std;

int main()
{
    int N;
    scanf("%d\n",&N);
    map<string,long long int> mp;
    char str[11];

    for(int i=0; i<N; i++)
    {
        scanf("%s\n",str);
        sort(str, str+10);
        mp[str]++;
    }

    //mp[str]=0;
    //mp[str]++;
    //printf("%lld\n",mp[str]);

    long long int res=0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        long long int c=itr->second;
        res += c*(c-1)/2;
        //printf("%lld\n",itr->second);
    }
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long 
    #define ull unsigned long long 
    #define ld long double
    #define fi first
    #define se second
    #define pb push_back
    #define mp make_pair
    ll mod=1e9+7;
 
     ll a[200005];
       ll b[200005];
 
     ll idx[100005][2];
    // ll cnt[200005];
     ll pre[200005];
    // ll end[200005];
     map<ll,ll> m;
 
    bool comp(const pair<ll,ll>& a, const pair<ll,ll>& b){
      return (a.fi-a.se)>(b.fi-b.se);
    }
 
    bool revcomp(const pair<ll,ll>& a, const pair<ll,ll>& b){
      return (a.fi)>(b.fi);
    }
 
 
    ll ceil1(ll a, ll b){
      if(a%b!=0)return a/b+1;
      else return a/b;
    }
    ll power(ll a,ll b,ll n){ll ans=1;while(b>0){if(b%2==1)ans=(ans*a)%n;a=(a*a)%n;b/=2;}return ans;}
 
    ll count1=0;
 
 
    ll gcd(ll a, ll b){
      //if(a<b)swap(a,b);
      if(b==0)return a;
      return gcd(b,a%b);
    }
 
  ll primepos(ll fact, ll p) 
  { 
      ll res = 0; 
      while (fact > 0) {         
          res += fact / p; 
          fact /= p;  
      } 
    
      return res; 
  } 
 
  // void dfs(ll n, ll p){
  //   if(vis[n]!=0){
  //     return;
  //   }
  //   else{
  //     vis[n]=1;
  //     b[n]=p;
  //     for(int i=0;i<v[n].size();i++){
  //       dfs(v[n][i],p);
  //     }
  //   }
  // }

   int main(){

      ios::sync_with_stdio(0);
     
      int n;
      cin>>n;
      for(int i=0;i<n;i++){
        cin>>a[i];
      }
      int dp[n+1];
      memset(dp,0,sizeof dp);
      dp[0]=0;
      dp[1]=abs(a[1]-a[0]);
      for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
      }
      cout<<dp[n-1]<<endl;
      return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <iomanip>
#define pi 3.14159265358979323846
using namespace std;

int main()
{
	int H,W,i,j;
	while(true)
	{
		cin>>H>>W;
		if(H!=0||W!=0){
			
			for(i=1;i<=H;i++)
			{
				if(i==1||i==H)
					{
					for(j=1;j<=W;j++)
						{
							cout<<'#';
						}
					cout<<endl;
					} 
				else
				{
					cout<<'#';
					for(j=2;j<W;j++)
						cout<<'.';
					cout<<'#'<<endl;
				}
				
			}
		
		}
		else
			return 0; 
		cout<<endl;
	}
}
 


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

using namespace std;

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

const double pi = acos(-1.0);

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

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

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    ll a,b,c,d;
    cin >> a >>b >>c >> d;
    cout << ((abs(a-c)<=d || (abs(a-b)<=d&&abs(b-c)<=d))?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/abc082/editorial.pdf
　　　https://atcoder.jp/contests/abc082/submissions/3930644
・メモリ節約のため、dictをsetにした。
・さらに使い終わった1つ前はもういらないので消すことにした。
・あとちょっと初期化とか色々調整
"""

S = input()
X, Y = map(int, input().split())

S2 = []
tmp = 0
# 連続するF毎にまとまるように文字列Sを変形させる
for i in range(len(S)):
    if S[i] == 'F':
        tmp += 1
        if i == len(S)-1:
            S2.append(tmp)
    # T毎に区切る
    else:
        S2.append(tmp)
        tmp = 0

# あるかないか分かればいいので、dictじゃなくてsetにする
dpx = [set() for _ in range(len(S2))]
dpy = [set() for _ in range(len(S2))]
# xの初期化：step0は右移動固定
dpx[0].add(S2[0])
# yの初期化：step0は何も動かないので座標0
dpy[0].add(0)
for i in range(1, len(S2)):
    # 左右に移動する
    for v in dpx[i-1]:
        if i % 2 == 0:
            # 到達可能な位置から+-した位置に送る
            dpx[i].add(v-S2[i])
            dpx[i].add(v+S2[i])
        else:
            # yをやる時はxはそのまま
            dpx[i].add(v)
    # 1つ前は使い終わったので削除
    dpx[i-1] = set()
    # 上下に移動する
    for v in dpy[i-1]:
        if i % 2 == 1:
            dpy[i].add(v-S2[i])
            dpy[i].add(v+S2[i])
        else:
            dpy[i].add(v)
    dpy[i-1] = set()

# 最後のstepでXとYが到達可能ならOK
if X in dpx[-1] and Y in dpy[-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 159112
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let t: String = read();

    let mut s: Vec<u32> = s.chars().map(|c| ((c as u8) - b'0') as u32).collect();
    let mut t: Vec<u32> = t.chars().map(|c| ((c as u8) - b'0') as u32).collect();
    s.sort();
    t.sort_by(|x, y| x.cmp(y).reverse());
    let len = if s.len() <= t.len() {
        s.len()
    } else {
        t.len()
    };
    
    for i in (0..len) {
        if s[i] < t[i] {
            println!("Yes");
            return;
        } else if s[i] > t[i] {
            println!("No");
            return;
        }
    }

    println!("{}", if s.len() < t.len() {"Yes"} else {"No"});
}


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

int main () {
  int N;
  cin >> N;
  
  vector<int> H(N); 
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
 
  int count = 0, result = 0;
  for (int i = 0; i < N-1; i++) {
    if (H.at(i) >= H.at(i+1)) {
      count++;
    } else {
      count = 0;
    }
    
    result = max(result, count);
  }
  
  cout << result;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;

int main()
{
	int N, m6, m9;
	cin >> N;

	int ans = N;


	/*
	int  n = N;
	for (int i = v.size()-1; i >= 0; i--) {
		while (v[i] <= n) {
			n -= v[i];
			ans++;
		}
	}
	
	for (int i = 0; i < v.size(); i++) {
		cout << v[i] << endl;
	}*/
	/*
	int i = 1;
	while (pow(6, i) <= 10000) {
		mems.push_back(N/((int)pow(6, i)));
		memz.push_back(N%((int)pow(6, i)));
		i++;
	}

	int i = 1;
	while (pow(9, i) <= 10000) {
		mems.push_back(N / ((int)pow(9, i)));
		memz.push_back(N % ((int)pow(9, i)));
		i++;
	}
	*/


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

		int res = i;
		while(res != 0) {
			count += res%6;
			res = res/6;
		}

		res = N - i;
		while (res != 0) {
			count += res % 9;
			res = res / 9;
		}
/*
		if (m6+m9>11) {
			count -= 10;
		}
		else if (m6 + m9>5) {
			count -= 5;
		}
*/
		if (ans > count) ans = count;
	}

	cout << ans;

	char qq;
	cin >> qq;
	return 0;
}


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

OPT = [0 for i in range(N)]
for i in range(1, N):
	OPT[i] = OPT[i-1]+min((X[i]-X[i-1])*A, B)
print(OPT[N-1])

Measured memory_bytes: 14224
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define INF 1e9

static const int seed=6;
static const int D=365;
static const int ntype=26;
static int ans[D+1];
static int max_score=-INF;
static int t=1e5;
class Contest{
public:
    Contest(){
        last=0;
    }
    int s[D+1];
    int c;
    int last;
};

static Contest contest[ntype+1];

void Input(){
    int d;
    cin>>d;
    for(int i=1;i<=ntype;++i){
        int t;
        cin>>t;
        contest[i].c=t;
    }
    for(int day=1;day<=D;++day){
        for(int type=1;type<=ntype;++type){
            int t;
            cin>>t;
            contest[type].s[day]=t;
        }
    }
}

int evaluate(){
    int sum=0;
    vector<int> l(ntype+1,0);
    for(int day=1;day<=D;++day){
        int type=ans[day];
        sum+=contest[type].s[day];
        l[type]=day;
        for(int t=1;t<=ntype;++t){
            sum-=contest[t].c*(day-l[t]);
        }
    }
    return sum;   
}

void Output(){
    for(int d=1;d<=D;++d) cout<<ans[d]<<endl;
}

void Init(){
    for(int d=1;d<=D;++d) ans[d]=rand()%ntype+1;
}

void Greedy(){
    vector<int> l(ntype+1,0);
    int score=0;
    for(int d=1;d<=D;++d){
        for(int i=1;i<=ntype;++i) score-=contest[i].c*(d-l[i]);
        int temp=score;
        int t=-1;
        for(int i=1;i<=ntype;++i){
            int k=contest[i].s[d]+contest[i].c*(d-l[i])+score;
            if(k>temp){
                temp=k;
                t=i;
            }
        }
        ans[d]=t;
        l[t]=d;
    }
}

void solve(int time){
    bool seen[D+1][ntype+1];
    max_score=evaluate();
    for(int i=0;i<time;++i){
        int p=rand()%D+1;
        int change=rand()%ntype+1;
        if(seen[p][change]) continue;
        seen[p][change]=true;
        int temp=ans[p];
        ans[p]=change;
        int temp_score=evaluate();
        if(max_score<temp_score){
            max_score=temp_score;
        }
        else ans[p]=temp;
    }
}

int main(){
    srand(seed);
    Input();
    Greedy();
    solve(t);
    Output();
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

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 main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin>>n;
	vi a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	cout<<a.back()-a.front()<<endl;
	return 0;
}


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

class Program
{
    static void Solve()
    {
        Console.WriteLine((ReadInt() - 2) * 180);
    }


    static void Main(string[] args)
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();

    }

    public static string Read() { return Console.ReadLine(); }
    public static int ReadInt() { return int.Parse(Read()); }
    public static long ReadLong() { return long.Parse(Read()); }
    public static double ReadDouble() { return double.Parse(Read()); }

    public static string[] Reads() { return Console.ReadLine().Split(' '); }
    public static int[] ReadInts() { return Reads().Select(_ => int.Parse(_)).ToArray(); }
    public static long[] ReadLongs() { return Reads().Select(_ => long.Parse(_)).ToArray(); }
    public static double[] ReadDoubles() { return Reads().Select(_ => double.Parse(_)).ToArray(); }
}

Measured memory_bytes: 11092