akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

typedef pair<int,int> PI;
typedef pair<int,pair<int,int>> PII;
static const int INF=1010000000000000017LL;
static const double eps=1e-12;
static const double pi=3.14159265358979323846;
static const int dx[4]={1,-1,0,0};
static const int dy[4]={0,0,1,-1};

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

int X,Y;

signed main(){
    cin>>X>>Y;
    int y=-X+Y/2;
    int x=Y-X-3*y;
    if(x<0||y<0)cout<<"No"<<endl;
    else if(x+y==X&&2*x+4*y==Y)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#define fi first
#define se second
using namespace std;
short n;
int b[111],c[111],sum;
int main(){
    scanf("%hd",&n);
    for (short i=1;i<n;++i) scanf("%d",&b[i]);
    b[0]=b[n]=1000000000;
    for (short i=1;i<=n;++i)
        c[i]=min(b[i],b[i-1]),sum+=c[i];
    printf("%d",sum);
}


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

class Program
{
    public static void Main()
    {
        while (true)
        {
            int sum = 0;
            string str = Console.ReadLine();
            if (str == "0") break;
            foreach (var c in str) sum += c - '0';
            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 17928
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    cout << max(0, a - 2 * b) << endl;
}

Measured memory_bytes: 768
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = S()
c0 = s.count('0')
c1 = s.count('1')
print(2*min(c0, c1))

Measured memory_bytes: 39472
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  string S;
  cin >> S;
  ll i;
  bool ans = true;
  for(i=0;i<S.length();i+=2){
    if(S[i]=='L') ans = false;
  }
  for(i=1;i<S.length();i+=2){
    if(S[i]=='R') ans = false;
  }
  if(ans){
    cout << "Yes";
  }else{
    cout << "No";
  }
  
}


Measured memory_bytes: 256
import copy
n = int(input())
*A, = map(int, input().split())


def solve(p):
    r = 0
    t = 0
    for a in A:
        t += a
        if t * p <= 0:
            r += abs(p - t)
            t = p
        p *= -1
    return r


print(min(solve(1), solve(-1)))


Measured memory_bytes: 68332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define pb push_back 
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sz(v) (int((v).size()))
const ll INF = 1e18;
const int MOD = 1e9+7;
const int N = 1e2+5;
vector<int> adj[N];
void dfs(int u, int p, int depth, vector<int> &max_children){
	int cnt_c = 0;
	for(int v : adj[u]){
		if(v == p)
			continue;
		++cnt_c;
		dfs(v,u,depth+1,max_children);
	}
	max_children[depth] = max(max_children[depth],cnt_c);
}
pair<ll,ll> solve(int r1, int r2){
	vector<int> mc1(100), mc2(100);
	dfs(r1,r2,0,mc1);
	dfs(r2,r1,0,mc2);
	int md = 0;
	while(mc1[md] > 0 || mc2[md] > 0)
		++md;
	ll ans = 1;
	for(int i = 0; i < md; ++i)
		ans *= max(mc1[i],mc2[i]);
	if(r1 != r2)
		ans *= 2;
	return mp(md+1,ans);
}
int main(){
	int n;
	cin >> n;
	vector<pair<int,int> > edges;
	for(int i = 0; i < n-1; ++i){
		int a,b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
		edges.pb(mp(a,b));
	}
	pair<ll,ll> ans = {101,0};
	for(auto cur : edges){
		auto res = solve(cur.first,cur.second);
		ans = min(ans,res);
	}
	for(int i = 1; i <= n; ++i){
		auto res = solve(i,i);
		ans = min(ans,res);
	}
	cout << ans.first << ' ' << ans.second << '\n';
}



Measured memory_bytes: 256
n = int(input())
l = []
cnt = 0
odd = []
for j in range(1,n+1):
    if j % 2 == 1:
        odd.append(j)
for k in odd:
    l = []
    for s in range(1,k+1):
        if k % s == 0:
            l.append(s)
        if len(l) == 8:
            cnt += 1
print(cnt)


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);

  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }

  int x = 1;
  int i = 0;

  while (i < N) {
    x = vec.at(x - 1);
    i++;
    if (x == 2) {
      break;
    }
  }

  if (x != 2) {
    cout << -1 << endl;
  }
  else {
    cout << i << endl;
  }

}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}

ll call(ll a,ll b,ll c)
{
    ll res=0;
    if(a%c==0)res++;
    res+=(b-a+a%c)/c;
    return res;
}
int main()
{
    ll a,b,c,d,ac;
    cin>>a>>b>>c>>d;
    ll ans=call(a,b,c)+call(a,b,d)-call(a,b,c*d/gcd(c,d));
    ans=(b-a+1)-ans;
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+10;

int n,a[N];
ll f[N],s[N];

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		s[i]=(i>1?s[i-2]:0)+a[i];
	}
	for(int i=2;i<=n;i++)
		if(i&1) f[i]=max(f[i-1],f[i-2]+a[i]);
		else f[i]=max(s[i-1],f[i-2]+a[i]);
	printf("%lld\n",f[n]);return 0;
}


Measured memory_bytes: 5640
import math
import collections
def primes(n):
    a = list(range(2, n+1))
    primes = [2]
    for i in a:
        flag = True
        m = math.sqrt(i)
        for j in primes:
            if j > m:
                break
            else:
                if i % j == 0:
                    flag = False
                    break
        if flag:
            primes.append(i)
            
    return primes
p = primes(1000)
dic = collections.defaultdict(int)
N = int(input())
mod = 10**9 +7
for i in range(1, N+1):
    for j in p:
        while i % j == 0:
            dic[j] += 1
            i = i // j
    ans = 1
for c in dic.values():
    ans *= (c+1)
    ans %= mod
print(ans)

Measured memory_bytes: 3316
fn main() {
  let n: usize = read();
  let ps: Vec<usize> = read_vec();
  
  let mut seqa: Vec<usize> = vec![];
  let mut seqb: Vec<usize> = vec![];
  let step = 20001;
  
  for d in 0 .. n {
    seqa.push(step * d + ps.iter().position(|&p|p==d+1).unwrap() + 1);
    seqb.push(step * (n - d));
  }
  
  print_vec(&seqa, " ");
  print_vec(&seqb, " ");
}

fn print_vec<T: std::string::ToString>(vec: &Vec<T>, sep: &str) {
  let out = vec.iter().map(|e| e.to_string()).collect::<Vec<_>>().as_slice().join(sep);
  println!("{}", out);
}

fn read<T: std::str::FromStr>() -> T {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().parse::<T>().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).ok();
  buf.trim().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
}


Measured memory_bytes: 6780
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  cout << pow(n, 3) << endl;
  return 0;
}

Measured memory_bytes: 256
a,b,c,k=map(int,input().split())
count=0
if a>=k:
  print(k)
else:
  n=k-a
  count=a
  if b>=n:
    print(a)
  else:
    m=n-b
    if c>=m:
      l=c-m
      p=k-a-b
      print(a-p)
    else:
      print(a-c)


Measured memory_bytes: 9180
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

ll A, B;

int main() {
    fast_io;

    cin >> A >> B;
    cout << A * B / __gcd(A, B) << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n,score,i;
	int max = 0, min = 10000, sum;
	
	while(scanf("%d", &n), n != 0){
		while(n-- > 0){
			sum = 0;
			for(i = 0; i < 5; i ++){
				scanf("%d", &score);
				sum += score;
			}
			if(sum > max){
				max = sum;
			}
			if(sum < min){
				min = sum;
			}
		}
		printf("%d %d\n", max, min);
		max = 0;
		min = 10000;
	}
	
	return(0);
}

Measured memory_bytes: 600
s = input()
n = len(s)
sformer = s[:int((n - 1) / 2)]
slatter = s[int((n + 1) / 2):]
if s == s[-1::-1] and sformer == sformer[-1::-1] and slatter == slatter[-1::-1]:
  print('Yes')
else:
  print('No')


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'

int main(){
    int n;
    cin >> n;
    map<int, int> m;
    vector<int> a(n);
    for(int i=0; i<n; ++i){
        cin >> a[i];
        m[a[i]]++;
    }

    ull tp = 0;
    for(auto x:m){
        if(x.second)
            tp += 1.0*x.second*(x.second-1)/2;
    }

    for(int i=0; i<n; ++i){
        ull p = 1.0*(m[a[i]])*(m[a[i]]-1)/2;
        ull nw = 1.0*(m[a[i]]-1)*(m[a[i]]-2)/2;
        cout << tp - p + nw << endl;
    }
}


Measured memory_bytes: 10100
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

int main(){
	int n,m,car=0,ans;
	cin >> n >> m;
	car=m;
	ans=m;
	for(int i=0; i<n; ++i){
		int tmp1,tmp2;
		cin >> tmp1 >> tmp2;
		car = car+tmp1-tmp2;
		if(car<0) {
			cout << 0 << "\n";
			return 0;
		}
		ans=max(ans,car);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void){
    int i,n,pm,pe,pj;
    while(1){
        scanf("%d",&n);
        if(n==0){
            break;
        }
        for(i=0;i<n;i++){
            scanf("%d %d %d",&pm,&pe,&pj);
            if(pm==100 || pe==100 || pj==100){
                printf("A\n");
            }else if(((pm+pe)/2)>=90){
                printf("A\n");
            }else if(((pm+pe+pj)/3)>=80){
                printf("A\n");
            }else if(((pm+pe+pj)/3)>=70){
                printf("B\n");
            }else if((((pm+pe+pj)/3)>=50) && (pm>=80 || pe>80)){
                printf("B\n");
            }else{
                printf("C\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2048
#include<iostream>

using namespace std;

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

bool able[1000001];
int n, m, k;

int main(){
    cin >> n >> m >> k;
    REP(i, n*m+1) able[i] = false;

    REP(i, n+1){
        REP(j, m+1){
            able[(i)*(j) + (n-i)*(m-j)] = true;
        }
    }

    if(able[k]){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

vector<ll> divisor(ll a){
    vector<ll> ret;
    for(ll i = 1; i*i <= a; i++){
        if(a % i == 0){
            ret.push_back(i);
            if((a/i) != i)
                ret.push_back(a/i);
        }
    }

    return ret;
}

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll>  A(N);
    ll sum = 0;
    REP(i,N){
        ll a;
        cin >> a;
        sum += a;
        A[i] = a;
    }

    auto div = divisor(sum);

    ll ans = 1;
    for(auto&& x : div){
        if(x < ans) continue;
        vector<ll> B(N);
        REP(i,N) B[i] = A[i] % x;
        sort(B.begin(), B.end());

        vector<ll> down(N);
        vector<ll> up(N);

        REP(i,N){
            down[i] = B[i];
            if(i != 0) down[i] += down[i-1];
        }

        for(int i = N-1; i >= 0; i--){
            up[i] = x - B[i];
            if(i != N-1) up[i] += up[i+1];
        }

        bool valid = false;
        REP(i,N-1)
            if(down[i] == up[i+1] && down[i] <= K)
                valid = true;

        if(valid)
            chmax(ans, x);
    }

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


Measured memory_bytes: 256
///بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
///La ilaha illallahu muhammadur rosulullah
#include<bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
using namespace std;
int main()
{
    fast;
    int n,ans;
    cin>>n;
    ans = pow(n,3);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);i=i+1)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	int N;
	cin >> N;
	vector<int>A(N); IN(A);
	vector<int>H(N + 1, 0);
	R(i, N) {
		H[A[i]]++;
	}
	vector<int> B;
	for (int i = 1; i <= N; ++i) {
		if (H[i]) {
			B.push_back(H[i]);
		}
	}
	SO(B);
	vector<int> BB(B.size()+1, 0);
	for (int i = 0; i < B.size(); ++i) {
		BB[i+1] = BB[i] + B[i];
	}
	for (LL k = 1; k <= N; ++k) {
		LL L = 0;
		LL R = N+1;
		while (L + 1 < R) {
			LL T = (L + R) / 2;
			int index = lower_bound(B.begin(), B.end(),T)-B.begin();
			LL cnt = B.size() - index;
			LL res = BB[index] + cnt * T;
			if (res >= T * k) {
				L = T;
			}
			else {
				R = T;
			}
		}
		cout << L << endl;
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

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

int main() {
  string a;
  cin>>a;
  for(int i=0;i<3;i++){
    if(a.at(i)=='1'){
      a.at(i)='9';
    }
    else{
      a.at(i)='1';
    }
  }
    cout<<a<<endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  rep(i, n) cin >> t[i];
  int m;
  cin >> m;
  vector<int> p(m), x(m);
  rep(i, m) cin >> p[i] >> x[i];
  rep(i, m) --p[i];

  rep(i, m) {
    int s = 0;
    rep(j, n) {
      if (j == p[i]) s += x[i];
      else s += t[j];
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3572
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1e15+7;
const ll mod = 1e9 + 7;
const int MAX_N = 1e5 + 5;
int dx[] = { -1LL,0,1LL,0 }, dy[] = { 0,1LL,0,-1LL };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1LL; while (b > 0) { if (b & 1LL) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1LL] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) { a[i] = 1LL; }for (int i = 2; i < n + 1LL; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

vector<vector<int>> kake(vector<vector<int>> &tim1,vector<vector<int>> &tim2) {
	vector<vector<int>> res = vector<vector<int>>(tim1.size(),vector<int>(tim1[0].size(),0));
	REP (i,tim1.size()) {
		REP (j,tim1[0].size()) {
			REP (k,tim2[0].size()) {
				res[i][k] += tim1[i][j] * tim2[j][k];
				res[i][k] %= mod;
			}
		}
	}
	return res;
}

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}

//8500±index;

signed main() {
	string s;
	cin >> s;
	int ans = s.size();
	int count = s.size();
	FOR (i,1,count) {
		if (s[i] != s[i-1]) {
			ans = min(ans,max(count - (ll)i,(ll)i));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
const log = console.log;

// ----

function Main(input: string): void {
  const [a, p] = input
    .trim()
    .split(/\s/g)
    .map(s => parseInt(s));

  const totalPieceCount = 3 * a + p;
  const pieCount = totalPieceCount >>> 1;

  log(pieCount);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
#define LL long long
#define mod 998244353
#define M 1000005
using namespace std;
int read()
{
	char ch=getchar(); int w=1,c=0;
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') w=-1;
	for (;isdigit(ch);ch=getchar()) c=(c<<3)+(c<<1)+(ch^48);
	return w*c;
}
LL f[M],inv_f[M],ans;
int n,m;
LL fast(LL x,LL p)
{
	LL res=1;
	for (;p;p>>=1,x=x*x%mod) if (p&1) res=res*x%mod;
	return res;
}
LL C(int n,int m){if (m>n) return 0;return f[n]*inv_f[m]%mod*inv_f[n-m]%mod;}
LL calc(int x,int y,int t){return C(x+y,y)-C(x+y,x+t);}
int main()
{
	n=read(); m=read();
	if(m<n) return puts("0")&0;
	f[0]=1;
	for(register int i=1;i<=m+n;++i)
	f[i]=f[i-1]*i%mod;
	inv_f[m+n]=fast(f[m+n],mod-2);
	for(register int i=m+n;i;--i) inv_f[i-1]=inv_f[i]*i%mod;
	for(register int i=0;i<=m;++i)
	{
		int R=i,B=m-i;
		if(R==B) ans=(ans+calc(R,B-1,R-n+1)+mod)%mod;
		if(R>B) ans=(ans+calc(R,B,R-n+1)+mod)%mod;
	}
	return printf("%lld",ans)&0;
}


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

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<"Draw";
    else if(a<b&&a!=1)
        cout<<"Bob";
    else if(b<a&&b!=1)
        cout<<"Alice";
    else if(a==1&&b>1)
        cout<<"Alice";
    else if(b==1&&a>1)
        cout<<"Bob";

    return 0;
}


Measured memory_bytes: 3632
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	q := nextInt() // 0.25 price
	h := nextInt() // 0.5 price
	s := nextInt() // 1.0 price
	d := nextInt() // 2.0 price
	n := nextInt() // require  price

	// 1リットルあたりprice
	p1 := 4 * q
	p2 := 2 * h
	p3 := 1 * s
	minp := min(min(p1, p2), p3)

	// 2リットルあたりprice
	q1 := 8 * q
	q2 := 4 * h
	q3 := 2 * s
	q4 := 1 * d
	minq := min(min(q1, q2), min(q3, q4))

	// 2リットル買えるだけ買う
	if n%2 == 0 {
		fmt.Println(n / 2 * minq)
		return
	}

	// 最後の1リットル安い
	fmt.Println(n/2*minq + minp)

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

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define kakkei vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{return f<p.f;};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{
		return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);
	};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
void solve(){
	ll n;cin>>n;
	rep(i,0,n){
		v2 s1,s2;
		ld a,b,c,d;
		cin>>a>>b>>c>>d;
		s1={a-c,b-d};
		cin>>a>>b>>c>>d;
		s2={a-c,b-d};
		if(s1.gaiseki(s2)==0)cout<<2<<kai;
		else if(s1.naiseki(s2)==0)cout<<1<<kai;
		else cout<<0<<kai;
	}
}


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

int a, b, c, d, p, x, y;
int main()
{
  cin >> a >> b >> c >> d >> p;
  x = a * p;
  if(p <= c) y = b;
  else y = b + d * (p - c);
  cout << min(x, y) << endl;
  return 0;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n, k; read(n, k);
	vector<int> v(n);
	rep(i, 0, n) read(v[i]);
	sort(all(v));
	int ans = 0;
	rep(i, 0, k) ans += v[i];
	write(ans);
}


Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
using namespace std;

long double abc(long double n,long double x1,long double x2,long double y1,long double y2)
{
	long double r;
	r = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	r /= n;
	return r;
}
int main()
{
	long double n;
	cin>>n;
	long double x[8],y[8];
	for(size_t i = 0; i<n; i++)
	{
		cin>>x[i]>>y[i];
	}
	long double ans = 0;
	for(size_t i = 0; i<n; i++)
	{
		for(size_t ii = 0; ii<n; ii++)
		{
			if(i!=ii)
			{
				ans =ans + abc(n,x[i],x[ii],y[i],y[ii]);
			}
		}
	}
	cout<<fixed<<ans<<endl;
	return 0;
}



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

int main()
{
	int n;
	cin>>n;
	for(int k=1;k<=n;k++)
	{
		printf("Case %d:\n",k);
		int s;cin>>s;
		for(int i=0;i<10;i++)
		{
			s=s*s;
			stringstream ss;
			ss<<s;
			string st=ss.str();
			reverse(st.begin(),st.end());
			for(int j=st.size();j<8;j++)st+="0";
			reverse(st.begin(),st.end());
			string ans;
			for(int j=2;j<2+4;j++)
			{
				ans+=st[j];
			}
			s=atoi(ans.c_str());
			cout<<s<<endl;
		}
	}
}

Measured memory_bytes: 1252
S,T=input(),input()
s,t=len(S),len(T)

for i in range(s-t+1):
  if all(c in "?"+d for c,d in zip(S[-i-t:],T)):
    S=S.replace("?","a")
    print(S[:-i-t]+T+S[s-i:])
    quit()

print("UNRESTORABLE")


Measured memory_bytes: 2940
# coding: utf-8
N = int(input())
a = list(map(int, input().split()))

find=0
break_sum=0
cnt=0
for i in range(N):
    if a[i] == (find+1):
        break_sum+=cnt
        find+=1
        cnt=0
    else:
        cnt+=1
break_sum+=cnt
if min(a)!=1:
    break_sum=-1
print(break_sum)

Measured memory_bytes: 77516
#C
from collections import Counter
n = int(input())
v = list(map(int,input().split()))
e = []
o = []
for i in range(len(v)):
    if i%2 == 0:
        e.append(v[i])
    else:
        o.append(v[i])
    
c_e = Counter(e)
c_o = Counter(o)

e_m = c_e.most_common()
o_m = c_o.most_common()

result1 = 10**5+1
result2 = 10**5+1
result3 = 10**5+1
r1 = len(e) - e_m[0][1]
r2 = len(o) - o_m[0][1]
result1 = r1 + r2
if o_m[0][0] == e_m[0][0]:
    if len(o_m) > 1:
        result2 = r1 + len(o) - o_m[1][1]
    if len(e_m) > 1:
        result3 = len(e)-e_m[1][1] + r2
    else:
        result2 = len(e)
    print(min(result2,result3))
else:
    print(result1)

Measured memory_bytes: 23776
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a,b;
  cin >> a >> b;
  if(a<b)cout << "<";
  if(a==b)cout << "=";
  if(a>b)cout << ">";
}
  /*cin >> a;
  for(long long i=1;i<=a;i++){
    if(strlen(a)%2==1)l++;
  }
  cout << l;
}
*/


Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    H, A = map(int, input().split())
    print(ceil(H, A))


def main():
    solve()


if __name__ == '__main__':
    main()


Measured memory_bytes: 9988
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> p;
vector<ll>v;
ll arr[200001];
int main()
{
    ll n,k,a,b,c,ans=0;
    cin >>n;
    for(ll i=0;i<n;i++)
    {
    	cin >> arr[i];
        ans^=arr[i];
    }
//   cout<<arr[1]<<endl;
    for(ll i=0;i<n;i++)
    {
        b=ans^arr[i];
        cout << b<<" "; 
    }
    cout << endl;
    return 0;
}


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

int main() {
	int n; cin >> n;
	vector<char> s(n); rep(i, 0, n) cin >> s[i];

	string ans = "Three";
	rep(i, 0, n) {
		if (s[i] == 'Y') {
			ans = "Four";
			break;
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int N;
	cin >> N;
	vector<long long>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		A[i] -= (i + 1);
	}
	sort(A.begin(), A.end());
	long long ans = 0;
	long long b = A[N / 2];
	for (int i = 0; i < N; ++i) {
		ans += abs(A[i] - b);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4812
#include <iostream>
#include <string>

int main(){
 std::string S,T;
 std::cin>>S>>T;

 int ans=0;
 for(int i=0;i<S.size();i++){
  if(S[i]!=T[i]){
   ans++;
  }
 }
 std::cout<<ans<<std::endl;

 return 0;
}

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

using namespace std;

typedef long long ll;
const double eps=1e-6,pi=acos(-1);
const int N=1e3+5,M=1e9+7,SEGM=4*N,OO=0x3f3f3f3f;
int t,n,m;
char grid[N][N];
int mem[N][N];

bool valid(int r,int c){
    return r>-1&&c>-1&&r<n&&c<m&&grid[r][c]!='#';
}

int solve(int i=0,int j=0){
    if(i==n-1&&j==m-1) return 1;
    int &ret=mem[i][j];
    if(~ret) return ret;
    ret=0;
    if(valid(i+1,j)) ret=(ret%M+solve(i+1,j)%M)%M;
    if(valid(i,j+1)) ret=(ret%M+solve(i,j+1)%M)%M;
    return ret;
}

int main(){
    //freopen("myfile.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;++i)
        scanf("%s",grid+i);
    memset(mem,-1,sizeof mem);
    printf("%d",solve());
    return 0;
}


Measured memory_bytes: 8860
N = int(input())
S = list(input())

l = [0]*N
r = [0]*N
l[0] = 1 if S[0] == 'W' else 0
r[-1] = 1 if S[-1] == 'E' else 0

for i in range(1,N):
    j = -(i+1)
    l[i] = l[i-1] + (1 if S[i] == 'W' else 0)
    r[j] = r[j+1] + (1 if S[j] == 'E' else 0)

l.insert(0,0)
l.append(0)
r.insert(0,0)
r.append(0)

o = N
for i in range(N):
    o = min(o,l[i]+r[i+2])

print(o)

Measured memory_bytes: 29388
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 30005
#define INF 1000000005LL
#define MOD 1000000007

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

int n;
string s;

int a[12];
int c[SIZE][12];
int b[11][11][11];

int main(){
  cin >> n >> s;
  rep(i,0,12) c[n-1][i] = -1;
  for(int i=n-2;i>=0;i--){
    rep(j,0,10){
      c[i][j] = c[i+1][j];
      if((s[i+1]-'0') == j) c[i][j] = i+1;
    }
  }

  /*
  rep(i,0,n){
    rep(j,0,5){
      cout << c[i][j] ;
    }
    cout << endl;
  }
  */

  rep(i,0,n){
    int A = s[i]-'0';
    rep(j,0,10) rep(k,0,10){
      if(c[i][j] != -1){
        if(c[c[i][j]][k] != -1) b[A][j][k]=1;
      }
    }
  }

  int ans=0;
  rep(i,0,10) rep(j,0,10) rep(k,0,10){
    ans += b[i][j][k];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

    public static int ans(int stones[], int n){
        int storage[] = new int[n+1];
        storage[1] = 0;
        for(int i=2; i<=n; i++){
            int option1 = Math.abs(stones[i] - stones[i-1]) + storage[i-1];
            int option2 = (i==2) ? Integer.MAX_VALUE : Math.abs(stones[i] - stones[i-2]) + storage[i-2];
            storage[i] = Math.min(option1, option2);
        }
        return storage[n];
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int stones[] = new int[n+1];
        for(int i=1; i<=n; i++){
            stones[i] = sc.nextInt();
        }
        System.out.println(ans(stones, n));
    }
}

Measured memory_bytes: 51820
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);

int main() {
  ll W, H;
  cin >> W >> H;

  vi p(W), q(H);
  for (ll i = 0; i < W; i++) cin >> p[i];
  for (ll i = 0; i < H; i++) cin >> q[i];

  using tiii = tuple<ll, ll, ll>;
  priority_queue<tiii> pq;

  for (ll i = 0; i < W; i++) {
    pq.emplace(-p[i], 0, i);
  }

  for (ll i = 0; i < H; i++) {
    pq.emplace(-q[i], 1, i);
  }

  ll ans = 0;
  while (pq.size()) {
    ll h, i;
    tie(ignore, h, i) = pq.top();
    pq.pop();

    if (h) {
      ans += q[i] * (W + 1);
      H -= 1;
    } else {
      ans += p[i] * (H + 1);
      W -= 1;
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 9968
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    int N;
    cin >> N;
    
    int C[4] = {};
    for(int i = 0; i < N; i++){
        string S;
        cin >> S;
        if(S == "AC") C[0]++;
        if(S == "WA") C[1]++;
        if(S == "TLE") C[2]++;
        if(S == "RE") C[3]++;
    }
    
    cout << "AC x " << C[0] << endl;
    cout << "WA x " << C[1] << endl;
    cout << "TLE x " << C[2] << endl;
    cout << "RE x " << C[3] << endl;

}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#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<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
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<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int A;

int main(){
	cin>>A;
	if(A<=999) cout<<"ABC"<<endl;
	else cout<<"ABD"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int a, b, k; cin >> a >> b >> k;
  int now = 101;
  while(k--) {
    now--;
    while(a%now != 0 || b%now != 0) {
      now--;
    }
  }
  cout << now << endl;
}


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

# 番兵
R = []
R.append('.' + '.' * W + '.')
for c in S:
    R.append(['.'] + c + ['.'])

R.append('.' + '.' * W + '.')

#for line in R:
#    print(*line, sep="")

ret = []
for h in range(H):
    for w in range(W):
        count = 0
        # Rはxyともに+1したとこに対応
        if S[h][w] != '#':
            # 上
            if R[h][w] == '#': count += 1
            if R[h][w+1] == '#': count += 1
            if R[h][w+2] == '#': count += 1

            # 左右
            if R[h+1][w] == '#': count += 1
            if R[h+1][w+2] == '#': count += 1

            # 下
            if R[h+2][w] == '#': count += 1
            if R[h+2][w+1] == '#': count += 1
            if R[h+2][w+2] == '#': count += 1

            S[h][w] = str(count)

for line in S:
    print(*line, sep="")

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
int main() {
  int X, A, B;
  cin >> X >> A >> B;
  if (B-A <= 0) {
    cout << "delicious" << endl;
  } else if (B-A <= X) {
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

int main(){
  ll n,t;
  cin>>n>>t;
  vector<ll> a;
  for(int i=0;i<n;i++){
	ll x;
	cin>>x;
	a.push_back(x);
  }
  sort(a.begin(),a.end());
  ll dp[111111];
  dp[0]=1;
  for(int i=1;i<n;i++){
	ll k=a[i]-t;	
	ll l=lower_bound(a.begin(),a.end(),k)-a.begin();
	dp[i]=dp[i-1]*(i-l+1);
	dp[i]%=MOD;
  }
  cout<<dp[n-1]<<endl;
  return 0;
}



Measured memory_bytes: 4748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

int dp[101][N];

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n, k;
	cin >> n >> k;
	int a[n + 1];
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		for(int j = 0; j <= k; j++) {
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
			if(j + a[i] + 1 <= k) {
				dp[i][j + a[i] + 1] = (dp[i][j + a[i] + 1] - dp[i - 1][j] + mod) % mod;
			}
		}
		for(int j = 1; j <= k; j++) {
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
		}
	}
	cout << dp[n][k];

	return 0;
}

Measured memory_bytes: 81756
# -*- coding: utf-8 -*-
# C - Factors of Factorial
# 標準入力の取得
N = int(input())

# N以下の素数リストを作成
prime_number_list = []
for n in range(2, N+1):
    is_prime_number = True
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            is_prime_number = False
    if is_prime_number:
        prime_number_list.append(n)

# N!の約数の計算
# 各素因数の個数を求め、その個数+1をどんどん掛けていく
result = 1
for pn in prime_number_list:
    n = 1
    count = 0
    while pn**n <= N:
        count += N // (pn**n)
        n += 1
    result *= count + 1

# 結果出力
print(result%(pow(10,9)+7))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
//#define int long long
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


signed main() {
  string s;cin>>s;
  if(((s[6])-'0') >= 5 || s[5] == '1'){
    cout << "TBD" << endl;
  }else{
    cout << "Heisei" << endl;
  }
}


Measured memory_bytes: 256
import itertools
N,M,Q= list(map(int, input().split(' ')))
L=[]
for i in range(Q):
    L.append(list(map(int, input().split(' '))))
A=[i + 1 for i in range(M)]
As=list(itertools.combinations_with_replacement(A, N))
S=[]
s=0
for I in As:
    for J in L:
        if I[J[1]-1]-I[J[0]-1]==J[2]:
                s=s+J[3]
    S.append(s)
    s=0
print(max(S))

Measured memory_bytes: 25188
import fractions
a, b, c, d = map(int , input().split())
tmp = (c * d) // fractions.gcd(c, d)
ans = 0
ans += b - (b // c + b // d - b // tmp)
ans -= (a-1) - ((a-1) // c + (a-1) // d - (a-1) // tmp)
print(ans)

Measured memory_bytes: 5048
# https://beta.atcoder.jp/contests/abc112/tasks/abc112_a


def solve():
    age = int(input())

    if age == 1:
        print('Hello World')
    else:
        A = int(input())
        B = int(input())
        print(A + B)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cnt[] = new int[3];
		Arrays.fill(cnt, 0);
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			if(num <= a) cnt[0]++;
			else if(num <= b) cnt[1]++;
			else cnt[2]++;
		}
		int min = cnt[0];
		for(int i = 1; i < 3; i++) {
			if(min > cnt[i])min = cnt[i];
		}
		System.out.println(min);
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

int main() {
	string s; cin >> s;
	int n = s.size();
	deque<int> q; q.push_back(s[0]);
	int ans = 0;
	for (int i = 1; i < n; i++) {
		if (!q.empty() && q.back() != s[i]) q.pop_back(), ans+=2;
		else q.push_back(s[i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <stack>
using namespace std;
typedef long long ll;
const int N = 1e5 + 50;
char s[5];

int main( ){
    scanf("%s", s);
    int len = strlen(s);
    if (len == 2)
        printf("%s", s);
    else
    for (int i = 2; i >= 0; i--) {
        printf("%c", s[i]);
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    int n;
    std::cin >> n;

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

    std::vector<int> sorted = a;
    std::sort(sorted.begin(), sorted.end(), std::greater<int>());

    int max = sorted[0], second_max = sorted[1];

    for (auto elem : a) {
        std::cout << (elem == max ? second_max : max) << std::endl;
    }
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll X,Y,Z;
  cin>>X>>Y>>Z;
  ll N=X+Y+Z;
  using TP=tuple<ll,ll,ll>;
  vector<TP> A(X+Y+Z);
  for(auto &I:A){
    ll a,b,c;
    cin>>a>>b>>c;
    I=tie(a,b,c);
  }
  sort(A.begin(),A.end(),[](TP a,TP b){return get<1>(a)-get<2>(a)>get<1>(b)-get<2>(b);});
  ll ans=0,tmp=0;
  priority_queue<ll> Q;
  vector<ll> dp(N,-1e16);
  for(int i=0;i<N;i++){
    tmp+=get<1>(A[i]);
    Q.push({get<0>(A[i])-get<1>(A[i])});
    while((int)Q.size()>Y){
      tmp+=Q.top(); Q.pop();
    }
    if(Y<=i+1){dp[i]=tmp;}
  }
  tmp=0;
  while(!Q.empty()){Q.pop();}
  for(int i=N-1;i>0;i--){
    tmp+=get<2>(A[i]);
    Q.push({get<0>(A[i])-get<2>(A[i])});
    while((int)Q.size()>Z){
      tmp+=Q.top(); Q.pop();
    }
    if(N-Z>=i){ans=max(ans,tmp+dp[i-1]);}
  }  
  cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 4600
#include "bits/stdc++.h"
 
#define SORT(vec) sort(vec.begin(), vec.end());
#define REV(vec) reverse(vec.begin(), vec.end());
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------
 
	int N; cin >> N;
	vector<int> V;
	double ans;
 
	for (int i = 0; i < N; i++)
	{
		int v;
		cin >> v;
		V.push_back(v);
	}
	
	SORT(V);
	REV(V);
	
	for(int i = 0; i < V.size(); i++){
		if(i == V.size()-1){
			ans += 	V[i] / pow(2,i);
		}else{
			ans += 	V[i] / pow(2,i+1);
		}
		
	}
	
	cout << ans << "\n";
}

Measured memory_bytes: 384
import java.util.Scanner;

class Solver {
    public void Solve() {
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < a.length; i++) {
            if (a[i] % 2 == 0) {
                if (a[i] % 3 == 0 || a[i] % 5 == 0) {
                    continue;
                } else {
                    System.out.println("DENIED");
                    return;
                }
            }
        }
        System.out.println("APPROVED");
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


Measured memory_bytes: 22996