akhauriyash/Code-Regression huggingface dataset:
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	string b;
	cin >> b;
	if (b == "A")
		cout << "T" << endl;
	else if (b == "T")
		cout << "A" << endl;
	else if (b == "C")
		cout << "G" << endl;
	else if (b == "G")
		cout << "C" << endl;
	return 0;
}


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

struct BiMatch{
  Int L,R;
  vector<vector<Int> > G;
  vector<Int> match,level;
  
  BiMatch(){}
  BiMatch(Int L,Int R):L(L),R(R),G(L+R),match(L+R,-1),level(L){}
  
  void add_edge(Int u,Int v){
    G[u].push_back(v+L);
    G[v+L].push_back(u);
  }
  
  bool bfs(){
    queue<Int> q;
    for(Int i=0;i<L;i++){
      level[i]=-1;
      if(match[i]<0){
	level[i]=0;
	q.emplace(i);
      }
    }
    while(!q.empty()){
      Int v=q.front();q.pop();
      for(Int u:G[v]){
	Int w=match[u];
	if(w<0) return true;
	if(level[w]<0){
	  level[w]=level[v]+1;
	  q.emplace(w);
	}
      }
    }
    return false;
  }

  bool dfs(Int v){
    for(Int u:G[v]){
      Int w=match[u];
      if(w<0||(level[w]>level[v]&&dfs(w))){
	match[v]=u;
	match[u]=v;
	return true;
      }
    }
    return false;
  }
  
  Int build(){
    Int res=0;
    while(bfs())
      for(Int i=0;i<L;i++)
	if(match[i]<0&&dfs(i))
	  res++;
    return res;
  }
  
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n);
  vector<Int> c(n),d(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];
  for(Int i=0;i<n;i++) cin>>c[i]>>d[i];
  
  BiMatch bm(n,n);
  for(Int i=0;i<n;i++){
    for(Int j=0;j<n;j++){
      if(a[i]<c[j]&&b[i]<d[j]) bm.add_edge(i,j);
    }
  }

  cout<<bm.build()<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int ans = 0;
        if (A>=13) {
            ans = B;
        }else if(6<=A && A<=12){
            ans = B/2;
        }else{
            ans = 0;
        }
    System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 100005;

pii a[MAXN];
int n, ans;

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read();
	for (int i = 1; i <= n; i ++)
		a[i].xx = Read(), a[i].yy = i;
	sort(a + 1, a + n + 1);
	for (int i = 2; i <= n; i += 2)
		if (a[i].yy & 1)
			ans ++;
	return printf("%d\n", ans), 0;
}


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


def num(n):
    if n%2==0:
        if n%4==0:return n
        else:return n+1
    else:
        if (n+1)//2%2==0:return 0
        else:return 1


a,b=map(int,input().split())
print(num(a-1)^num(b))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)(a).size())

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

int n;
map<string, int> memo;
vector<string> mstr;
int get(string a){
  if(memo.count(a))
    return memo[a];
  int sz = SZ(memo);
  mstr.pb(a);
  return memo[a] = sz;
}

vector<PI> G[2000];
int vis[2000];
int vcnt;
bool app[2000][2000];

vector<int> cG[2000];

void solve(){
  memo.clear();
  mstr.clear();
  rep(i, n*2) G[i].clear();
  rep(i, n*2) cG[i].clear();
  
  set<PI> input;
  rep(i, n){
    string a, b;
    cin >> a;
    a[a.find('-')] = ' ';
    stringstream ss(a);
    ss >> a >> b;
    int u = get(a);
    int v = get(b);
    G[u].pb(mp(v,1));
    cG[u].pb(v);
    cG[v].pb(u);
    input.insert(mp(u, v));
  }
  
  
  cout << SZ(memo) << endl;
  rep(i, SZ(memo)) rep(j, SZ(memo)) app[i][j] = 0;
  for(auto e : input) app[e.F][e.S] = 1;

  
  // rep(d, SZ(memo)){
  //   sort(ALL(cG[d]));
  //   cG[d].erase(unique(ALL(cG[d])), cG[d].end());

  //   for(auto a : cG[d]) for(auto b : cG[d]){
  //       if(a == b) break;
        
  //       if(app[a][d] && app[d][b]) continue;
  //       if(app[b][d] && app[d][a]) continue;
  //       G[a].pb(mp(b,0));
  //       G[b].pb(mp(a,0));
  //     }
  // }

  rep(i, SZ(memo)) rep(j, i){
    bool ok = false;
    rep(k, SZ(memo))
      if((app[i][k]|app[k][i]) && (app[k][j]|app[j][k])){
        ok = true;
        break;
      }
    if(!ok) continue;
    ok = true;
    rep(k, SZ(memo)) if(app[i][k] && app[k][j]) ok = false;
    rep(k, SZ(memo)) if(app[j][k] && app[k][i]) ok = false;
    if(ok){
      G[i].pb(mp(j,0));
      G[j].pb(mp(i,0));
    }
  }
  
  rep(d, SZ(memo)){
    sort(ALL(G[d]));
    G[d].erase(unique(ALL(G[d])), G[d].end());
  }
  
  // rep(d, SZ(memo)){
  //   cout << mstr[d] << ": ";
  //   for(auto e : G[d])
  //     cout << mstr[e.F] << ",";
  //   cout << endl;
  // }
  
  int q;
  cin >> q;
  rep(i, q){
    string a, b;
    cin >> a;
    a[a.find('-')] = ' ';
    stringstream ss(a);
    ss >> a >> b;
    
    if(!(memo.count(a) && memo.count(b))){
      cout << "NO" << endl;
      continue;
    }
    
    int u = get(a);
    int v = get(b);
    queue<PI> q;
    q.push(mp(u,0));
    
    bool ok = false;
    ++vcnt;
    while(!q.empty()){
      int cv = q.front().F;
      int cc = q.front().S;
      q.pop();
      if(cv == v){
        //cout << "cc " << cc << endl;
        ok = cc & 1;
        break;
      }
      
      if(vis[cv] == vcnt) continue;
      //cout << mstr[cv] << endl;
      vis[cv] = vcnt;
      for(auto e : G[cv])
        if(vis[e.F] != vcnt)
          q.push(mp(e.F, cc + e.S));
    }
    
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
}

int main(int argc, char *argv[])
{
  while(cin >> n && n) solve();
  return 0;
}

Measured memory_bytes: 1896
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, k;
	cin>>n>>k;
	vector<int> arr;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		arr.push_back(a);
	}
	int dp[n];
	memset(dp,0,sizeof(dp));
	dp[0] = 0;
	for(int i=1;i<n;i++)
	{
		dp[i] = dp[i-1] + abs(arr[i] - arr[i-1]);
		int begin;
		if(i - k <0)	
			begin = 0;
		else
			begin = i - k;
		for(int j = begin; j<=i;j++)
		{
			dp[i] =	min(dp[i], dp[j] + abs(arr[i] - arr[j]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1144
ABC = list(map(int, input().split()))

tmp = 0
def calc(ABC, tmp):
        max_num = max(ABC)
        abs_list = [abs(max_num-i) for i in ABC]
        if all(i % 2 == 0 for i in abs_list):
                return int(sum(abs_list) / 2) + tmp
        else:
                cnt = 0
                for i, v in enumerate(abs_list):
                        if v % 2 == 0:
                                continue
                        else:
                                ABC[i] += 1
                                cnt += 1
                if cnt <= 1:
                        for i, v in enumerate(ABC):
                                if max_num == v:
                                        ABC[i] += 1
                                        break
                return calc(ABC, tmp+1)


                        

print(calc(ABC, 0))


Measured memory_bytes: 3064
n=int(input())
a=list(map(int, input().split()))
ans,c,d=0,1,True
while c<n:
    if a[c]==a[c-1]:
        c+=1
        continue
    if d:
        f=a[c]>a[c-1]
        d=False
    elif f:
        if a[c]<a[c-1]:
            ans+=1
            d=True
    else:
        if a[c]>a[c-1]:
            ans+=1
            d=True
    c+=1
print(ans+1)

Measured memory_bytes: 14252
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
class Solver{
public:
    static const int MAXN=6e5;
    int isprime[MAXN];
    void getPrime(){
        for(int u=0;u<MAXN;u++)isprime[u]=true;
        isprime[0]=isprime[1]=false;
        for(int u=2;u<MAXN;u++){
            if(!isprime[u])continue;
            for(int v=u+u;v<MAXN;v+=u)isprime[v]=false;
        }
    }
    void solve(){
        int N;
        cin>>N;
        getPrime();
        for(int u=0;u<MAXN&&N;u++){
            if(isprime[u]&u%10==1){
                cout<<u<<" ";
                --N;
            }
        }
    }
};
int main()
{
    // freopen("in.txt","r",stdin);
    (new Solver())->solve();
}

Measured memory_bytes: 2560
import collections

def combinations_count(n, r):
    return n * (n-1) // r


n = int(input())
l = [int(x) for x in input().split()]

l1 = []
l2 = []
c = collections.Counter(l)

total = sum([combinations_count(i, 2) for i in c.values()])

for a in l:
    print(total-combinations_count(c[a], 2)+combinations_count(c[a]-1, 2))


Measured memory_bytes: 26772
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N;
    string S;
    cin >> N >> S;
    Yes(N % 2 == 0 && S.substr(0, N / 2) == S.substr(N / 2, N / 2));
}


Measured memory_bytes: 256
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn main() {
    loop {
        let nums: Vec<u64> = get_line().trim()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let (n, x) = (nums[0], nums[1]);
        if n == 0 && x == 0 {
            break;
        }

        let mut count: usize = 0;
        for i in (1..n+1).rev() {
            for j in (1..i).rev() {
                let sum = i + j;
                if sum + 1 <= x && x <= sum + j - 1 {
                    count += 1;
                }
            }
        }
        println!("{}", count);
    }
}



Measured memory_bytes: 5024
#include <cstdio>

#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	int N{};
	cin >> N;

	string str = to_string(N);

	while (!all_of(str.begin(), str.end(), [&str](auto x) {
		return str[0] == x;
	})) {
		N++;
		str = to_string(N);
	}
	cout << N << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,l,r,c = 0;
    cin >> n;
    rep(i,n){
        cin >> l >> r;
        c += r-l+1;
    }
    PRINT(c);
}


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

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

namespace chrono = std::chrono;
using namespace std::literals;

[[gnu::constructor]]
void fast_iostream() {
    std::ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.tie(nullptr);
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << std::min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	long int n,a[5000],b[5000],i,j,max;
	
	while(0<=scanf("%ld",&n)){
		if(n==0)break;
		max=-2147483647;
		for(i=0;i<n;i++){
			scanf("%ld",&a[i]);
			if(max<a[i])max=a[i];
		}
		b[0]=a[0];
		for(i=1;i<n;i++){
			b[i]=b[i-1]+a[i];
			if(b[i]>max)max=b[i];
		}
		
		for(i=1;i<n;i++){
			for(j=i;j<n;j++){
				if(max<b[j]-b[i-1])max=b[j]-b[i-1];
			}
		}
		
		printf("%ld\n",max);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(){

	long long num1, num2,result;
	cin >> num1 >> num2;
	//num1 >= num2$B$K$9$k
	if (num1 < num2) {
		long long swap = num2;
		num2 = num1;
		num1 = swap;
	}
	if (num2 > 1) {
		result = (num1 - 2) * (num2 - 2);
		cout << result;
	}
	else if(num2 == 1) {
		if (num1 == 1) cout << 1;
		else cout << num1 - 2;
	}

	return 0;
}


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

const int offset = 1 << 20;
int st[2 * offset];
int in[offset];

int minimum(int a, int b) {
    a += offset;
    b += offset;

    int rv = 1e9 + 7;
    while(a <= b) {
        if(a % 2 == 1) rv = min(rv, st[a++]);
        if(b % 2 == 0) rv = min(rv, st[b--]);
        a /= 2; b /= 2;
    }
    return rv;
}


void add(int k, int x) {
    k += offset;
    st[k] = x;
    for(k /= 2; k >= 1; k /= 2) {
        st[k] = min(st[k * 2], st[k * 2 + 1]);
    }
}

int main() {
    int n, k;
    scanf("%d %d", &n, &k);

    for(int i = offset; i < offset * 2; i++) st[i] = 1e9 + 7;
    for(int i = 0; i < n; i++) {
        scanf("%d", &in[i]);
        add(i, in[i]);
    }

    int maxx = 0;
    for(int i = 1; i < n; ++i) {
        int v = minimum(0, i - 1);
        if(in[i] - v > maxx) {
           maxx = in[i] - v;
        }
    }

    int res = 0;
    set< int> st;
    st.insert(in[0]);
    for(int i = 1; i < n; ++i) {
        if(st.count(in[i] - maxx)) res++;
        st.insert(in[i]);
    }
    printf("%d\n", res);
}

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

namespace atCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var debug = false;

            var input = ReadLines(1);

            long S = long.Parse(input[0]);



            var result = GetSArea(S);

            Console.WriteLine(result);

            if(debug)
                Main(null);
        }

        static string GetSArea(long s)
        {
            if (s == (long)Math.Pow(10, 18))
                return "0 0 1000000000 0 0 1000000000";

            long x1 = (long)Math.Pow(10, 9);
            long y1 = 1;
            long y2 = 1 + s / x1;
            long x2 = x1 - (s % x1);
            return string.Format("{0} {1} {2} {3} {4} {5}",
                0,
                0,
                x1,
                y1,
                x2,
                y2);
        }

        static string[] ReadLines(int n)
        {

            string[] str = new string[n];
            return str.Select(_ => _ = Console.ReadLine()).ToArray();

        }
        

    }
}


Measured memory_bytes: 13396
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  int t=0;
  bool flg;
  while(cin>>a){
    //if(a=="00")break;
    flg=true;
    for(int i=0;i<(a.size()+1)/2;i++){
      if(a[i]!=a[a.size()-i-1])flg=false;
    }
    if(flg)t++;
  }
  cout<<t<<endl;
}

Measured memory_bytes: 1184
#mathモジュールのimportと標準入力
import math
i = int(input())
line = list(map(int,input().split()))

#変数の更新
n = line[0]

#最小公倍数を求めその最小公倍数と新しい数との最小公倍数を求める
for l in range(1,i):n = int(n * line[l] / math.gcd(n,line[l]))

#出力
print(n)


Measured memory_bytes: 5664
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	float a,b;
	int x;

	cin >> a  >> b;

	a = (a + b) / 2;

	x = a;

	if (a > x) {
		x = x + 1;
	}
	cout << x << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define PI 2 * acos(0.0)
#define MAX 1000000
#define INF 1000000 
#define M 1000000007
using namespace std;
int main(){
    FAST
    ll n;
    cin>>n;
    ll a[n];
    ll sum = 0;
    for(ll i = 0;i<n;i++){
        cin>>a[i];
        sum += a[i];
    }
    ll ans = 0;
    for(ll i= 0;i<n;i++){
        sum = sum - a[i];
        ans = ans%M + ( (sum%M)*(a[i]%M))%M;
    }
    cout<<ans%M<<endl;
}


Measured memory_bytes: 5172
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).
*/

main :-
    get_number(A),
    get_number(B),
    get_number(C),
    X is min(C, B div A),
    writeln(X).


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

int main() {
	int d, n, k;
	cin >> d >> n;

	if (d == 0)k = 1;
	else if (d == 1) k = 100;
	else k = 10000;

	if(n != 100)cout << (n*k) << endl;
	else cout << (101*k) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<queue>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
inline int read(){
    int v = 0,c = 1;char ch = getchar();
    while(!isdigit(ch)){
        if(ch == '-') c = -1;
        ch = getchar(); 
    }
    while(isdigit(ch)){
        v = v * 10 + ch - 48;
        ch = getchar(); 
    }
    return v * c;
}
long long n,k;
int main(){
	cin >> n >> k;
	if(k == 1){
		cout << 0;
		return 0;	
	}
	cout << max(1ll * 0,n - k);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Combination of Number Sequences
 */
public class Main {

	static int count;
	static int sum;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = Integer.parseInt(line.substring(0, line.indexOf(' ')));
			count = 0;
			sum = Integer.parseInt(line.substring(line.indexOf(' ') + 1));
			if (sum > 330) {
				System.out.println(0);
			} else {
				solve(0, n, 0);
				System.out.println(count);
			}
		}
	}

	static void solve(int n, int i, int s) {
		if (s > sum) {
			return;
		}
		if (i == 0) {
			if (s == sum) {
				count++;
			}
			return;
		}
		for (int j = 0; j < 10; j++) {
			if ((n & 1 << j) == 0) {
				solve(n | 1 << j, i - 1, s + i * j);
			}
		}
	}
}

Measured memory_bytes: 18552
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

vector<vector<li>> g;
vector<li> outdegs;
vector<bool> vis;

void insert(li leaf, li nonleaf) {
    if (outdegs[leaf] % 2) {
        cout << leaf + 1 << " " << nonleaf + 1 << endl;
        outdegs[leaf]++;
    } else {
        cout << nonleaf + 1 << " " << leaf + 1 << endl;
        outdegs[nonleaf]++;
    }
}
void dfs(li pos, li parent) {
    vis[pos] = true;
    for (int i = 0; i < g[pos].size(); ++i) {
        const li next = g[pos][i];
        if (next == parent) {
            continue;
        }
        if (vis[next]) {
            if (pos < next) {
                insert(next, pos);
            }
        } else {
            dfs(next, pos);
        }
    }
    if (parent != -1) {
        insert(pos, parent);
    }
}

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

    li n, m;
    cin >> n >> m;

    g = vector<vector<li>>(n);
    outdegs = vector<li>(n);
    vis = vector<bool>(n);
    for (int i = 0; i < m; ++i) {
        li a, b;
        cin >> a >> b;
        a--; b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    if (m % 2 == 1) {
        cout << -1 << endl;
        return 0;
    }

    dfs(0, -1);
    return 0;
}

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

int main(){
    while(true){
        int a,b,c;
        cin >> a >> b >> c;
        if(a == -1 && b == -1 && c == -1) break;
        
        if(a == -1 || b == -1){
            cout << "F" << endl;
        }else if(a + b >= 80){
            cout << "A" << endl;
        }else if(a + b >= 65){
            cout << "B" << endl;
        }else if(a + b >= 50 || a + b >= 30 && c >= 50){
            cout << "C" << endl;
        }else if(a + b >= 30){
            cout << "D" << endl;
        }else{
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    //1往復目は最短距離
    //2往復目は8分膨らむ
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    rep(i,tx-sx){
        cout<<"R";
    }
    rep(i,ty-sy){
        cout<<"U";
    }
    rep(i,tx-sx){
        cout<<"L";
    }
    rep(i,ty-sy){
        cout<<"D";
    }
    cout<<"D";
    rep(i,tx-sx+1){
        cout<<"R";
    }
    rep(i,ty-sy+1){
        cout<<"U";
    }
    cout<<"L";
    cout<<"U";
    rep(i,tx-sx+1){
        cout<<"L";
    }
    rep(i,ty-sy+1){
        cout<<"D";
    }
    cout<<"R"<<endl;
    return 0;
}

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

int main() {
    int R;
    cin >> R;

    if (R < 1200) {
        cout << "ABC" << endl;
    }
    else if (1200 <= R && R < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
 while (true) {
String str = sc.next(); 
if (str.equals("-")) {
break; }
int n = sc.nextInt();
for(int i=0;i<n;i++){
int a= sc.nextInt();
str = str.substring(a)+str.substring(0,a);
}
System.out.println(str);
}}}


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

int main(void) {
	using namespace std;
	string s;
	cin >> s;
	const int INF = 101;
	int result = INF;
	for(char c = 'a'; c <= 'z'; ++c) {
		int m = -INF;//sをcのみからなる文字列に変えるのにかかる最小回数
		for(int i = 0; i <= s.length(); ++i) {
			int count = 0;
			if(i == s.length() || s[i] == c) {//番兵を入れておく
				while(i - count != 0 && s[i - (count + 1)] != c) ++count;
			}
			if(m < count) m = count;
		}
		if(m != -INF && m < result) {
			result = m;
		}
	}
	cout << result << '\n';
	return 0;
}



Measured memory_bytes: 256
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine

paint wmin wmax hmin hmax [] = (wmax - wmin) * (hmax - hmin)
paint wmin wmax hmin hmax (xya : xyas)
  | a == 1 && x <= wmin = paint wmin wmax hmin hmax xyas
  | a == 1 && x > wmin && x < wmax = paint x wmax hmin hmax xyas
  | a == 1 && x >= wmax = 0
  | a == 2 && x <= wmin = 0
  | a == 2 && x > wmin && x < wmax = paint wmin x hmin hmax xyas
  | a == 2 && x >= wmax = paint wmin wmax hmin hmax xyas
  | a == 3 && y <= hmin = paint wmin wmax hmin hmax xyas
  | a == 3 && y > hmin && y < hmax = paint wmin wmax y hmax xyas
  | a == 3 && y >= hmax = 0
  | a == 4 && y <= hmin = 0
  | a == 4 && y > hmin && y < hmax = paint wmin wmax hmin y xyas
  | a == 4 && y >= hmax = paint wmin wmax hmin hmax xyas
  where
    [x, y, a] = xya

main = do
  [w, h, n] <- getIntList
  xyas <- getIntNList n
  print $ paint 0 w 0 h xyas


Measured memory_bytes: 3916
#include<bits/stdc++.h>
using namespace std;
int MIN=9999;
string S;

int main(){
    long long int N;
    int a[200002],b[200002];
    for(int i=0;i<200002;i++)
        b[i] = 0;
    cin >> N;
    for(int i=0;i<N;i++)
        cin >> a[i+1];

    for(int i=N;i>=1;i--){
        int kari=0;
        for(int j=i;j<=N;j+=i){
            kari += b[j];
        }
        if(kari % 2 != a[i]){
            b[i] = 1;
        }
    }
    int cnt=0;
    for(int i=1;i<=N;i++){
        cnt += b[i];
    }

    cout << cnt << endl;
    for(int i=1;i<=N;i++){
        if(b[i])
            cout << (i) << " ";
    }
    cout << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>

using namespace std;

int N, M;
string s;
int ac[100001];
int pn[100001];

int main()
{

	cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int p;
		cin >> p;
		cin >> s;
		if (!ac[p]) {
			if (s == "AC") {
				ac[p] = 1;
			}
			else {
				++pn[p];
			}
		}
	}

	int sum = 0, pnsum = 0;
	for (int n = 1; n <= N; ++n) {
		if (ac[n]) {
			sum++;
			pnsum += pn[n];
		}
	}

	cout << sum << ' ' << pnsum << endl;

	return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vi a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    ll sum = 0;
    rep(i, m) sum += b[i];
    int j = m, ans = 0;
    rep(i, n+1) {
        while (j>0 && sum>k) {
            --j;
            sum -= b[j];
        }
        if (sum > k) break;
        ans = max(ans, i+j);
        if (i<n) sum += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;
using P = pair<int, int>;

int main() {
    int a, b, ans = 0;
    cin >> a;
    if (400 <= a && a <= 599)
        cout << 8 << endl;
    else if (a >= 600 && a <= 799)
        cout << 7 << endl;
    else if (a >= 800 && a <= 999)
        cout << 6 << endl;
    else if (a >= 1000 && a <= 1199)
        cout << 5 << endl;
    else if (a >= 1200 && a <= 1399)
        cout << 4 << endl;
    else if (a >= 1400 && a <= 1599)
        cout << 3 << endl;
    else if (a >= 1600 && a <= 1799)
        cout << 2 << endl;
    else if (a >= 1800 && a <= 1999)
        cout << 1 << endl;
    return 0;
}

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

int main(){
    int A,B,M,X,Y,a,b,c,min_ans;
    cin >> A >> B >>M;

    vector<int> vec_a(A);
    vector<int> vec_b(B);
    X =100001;
    Y =100001;

for(int i =0; i<A; i++){
    cin >> vec_a.at(i);
    X = min(X,vec_a.at(i));
}

for(int i = 0; i < B; i++){
    cin>>vec_b.at(i);
    Y = min(Y,vec_b.at(i));
}

min_ans=X+Y;
for(int i=0; i < M; i++){
    cin >> a >> b >> c;
    int x;
    x=vec_a.at(a-1)+vec_b.at(b-1)-c;
    min_ans=min(min_ans,x);
}
    cout << min_ans<<endl;
}

Measured memory_bytes: 1024
import math

def eratosthenes(n):
    prime_list = []
    num_list=[i for i in range(2, n+1)]
    limit = math.sqrt(n)
    while True:
        if limit <= num_list[0]:
            return prime_list + num_list
        prime_list.append(num_list[0])
        num_list = [e for e in num_list if e % num_list[0] != 0]

er_list = eratosthenes(100000)
count = [0 for i in range(100000)]
j = 0
for i in range(er_list[-1]):
    if i == er_list[j]:
        j += 1
        if (i+1)//2 in er_list:
            count[i] = 1 
            
for i in range(1,len(count)):
    count[i]  = count[i]+count[i-1]
    
Q = int(input())
for i in range(Q):
    l, r = map(int, input().split())
    print(count[r]-count[l-1])

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int n;
vector<vector<int>> a(10, vector<int>(10));
vector<vector<vector<int>>> drop = {
  {{0, 1, 0},
   {1, 1, 1},
   {0, 1, 0}},
  {{1, 1, 1},
   {1, 1, 1},
   {1, 1, 1}},
  {{0, 0, 1, 0, 0},
   {0, 1, 1, 1, 0},
   {1, 1, 1, 1, 1},
   {0, 1, 1, 1, 0},
   {0, 0, 1, 0, 0}}
};
int dz[3] = {3, 3, 5};

bool can_paint(int y, int x, int mode) {
  int len = drop[mode].size();
  if (max(y, x) + len > 10) return false;
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < len; j++) {
      if (a[y + i][x + j] - drop[mode][i][j] < 0) return false;
    }
  }
  return true;
}

void paint(int y, int x, int mode) {
  for (int i = 0; i < dz[mode]; i++) {
    for (int j = 0; j < dz[mode]; j++) {
      a[y + i][x + j] -= drop[mode][i][j];
    }
  }
}

void undo(int y, int x, int mode) {
  for (int i = 0; i < dz[mode]; i++) {
    for (int j = 0; j < dz[mode]; j++) {
      a[y + i][x + j] += drop[mode][i][j];
    }
  }
}

bool rec(int y, int x, int rem) {
  if (rem < 0) return false;
  if (y == 10) return rem == 0;
  for (int i = 0; i < 3; i++) {
    if (!can_paint(y, x, i)) continue;
    paint(y, x, i);
    if (rec(y, x, rem - 1)) {
      cout << x + dz[i] / 2 << " " << y + dz[i] / 2 << " " << i + 1 << endl;
      return true;
    }
    undo(y, x, i);
  }
  if (a[y][x]) return false;
  if (rec(y + (x == 9), (x + 1) % 10, rem)) return true;
  return false;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> a[i][j];
    }
  }
  rec(0, 0, n);

  return 0;
}


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

// a quote from http://www.igaris.com/math/c.pdf

#define MOD (1000000000+7)

long long dp[1001];

long long C[1001][1001];



long long power( long long x, int n )
{
	if( n == 0 ) {
		return 1;
	}
	if( n % 2 ) {
		return x * power( x, n - 1 ) % MOD;
	}
	else {
		return power( x * x % MOD, n / 2 );
	}
}

int main()
{
	int n, k;
	cin >> n >> k;

	long long ans = 0;
	if( n >= k ) {
		// Pascal's triangle for combination
		C[0][0] = 1;
		for( int i = 1; i < 1001; i++ ) {
			for( int j = 0; j <= i; j++ ) {
				if( j == 0 || j == i ) {
					C[i][j] = C[i - 1][0];
				}
				else {
					C[i][j] = ( C[i - 1][j - 1] + C[i - 1][j] ) % MOD;
				}
			}
		}

		dp[1] = 1;
		for( int i = 2; i <= k; i++ ) {
			long long po = power( i, n ) % MOD;
			for( int j = 1; j < i; j++ ) {
				po -= ( C[i][j] * dp[j] ) % MOD;
				po %= MOD;
				if( po < 0 ) {
					po += MOD;
				}
			}
			dp[i] = po;
		}
		ans = dp[k];
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 10008
// 2019-04-09
// Accepted
// 00:00 sec

#include <cstdio>
#include <algorithm>
using namespace std;

int bubbleSort(int A[], int n);
void Print(int A[], int n, int cnt);


int main() {
    int N;
    int A[100];
    scanf("%d", &N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }

    int cnt = bubbleSort(A, N);
    Print(A, N, cnt);
}


void Print(int A[], int n, int cnt) {
    for (int i = 0; i < n; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
    printf("%d\n", cnt);
}

int bubbleSort(int A[], int n) {
    int cnt = 0, i = 0;
    bool flag = 1;
    while (flag) {
        flag = 0;
        for (int j = n-1; j > i; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j], A[j-1]);
                flag = 1;
                cnt++;
            }
        }
        i++;
    }

    return cnt;
}



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

int main()
{
	int g = 0, p = 0, ans = 0;
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); i++)
	{
		if (str[i] == 'p')
		{
			if (p+1 > g) ans--, g++;
			else p++;
		}
		else if (str[i] == 'g')
		{
			if (g >= p+1) ans++, p++;
			else g++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  int N, i;
  cin >> N >> i;
  
  cout <<  N + 1 - i << endl;

}


Measured memory_bytes: 256
"""
 // Author : snape_here - Susanta Mukherjee

"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip
else:
    _str = str
    str = lambda x=b"": x if type(x) is bytes else _str(x).encode()

    
#from collections import deque, Counter, OrderedDict,defaultdict
#from heapq import nsmallest, nlargest, heapify,heappop ,heappush, heapreplace
from math import ceil,floor,log,sqrt,factorial,pow,pi
#from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
#from decimal import *,threading



def ii(): return int(input())
def fi(): return float(input())
def si(): return input()
def mi(): return map(int,input().split())
def li(): return list(mi())

import math
 
def find_gcd(x, y): 
      
    while(y): 
        x, y = y, x % y 
      
    return x
 
def main():
 
    a=ii()
    s=si()
    if a>=3200:
        ans=s 
    else:
        ans="red"
    print(ans)    
    
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        if self.buffer.tell():
            return self.buffer.read()
        return os.read(self._fd, os.fstat(self._fd).st_size)

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", b" "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", b"\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip(b"\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 29292
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
ll A[100005], SUM[100005];

int main() {
  INCANT;
  cin >> N;
  rep(i, N) cin >> A[i];
  sort(A, A+N);
  SUM[0] = A[0]; 
  rep(i, N) {
    if (i==0) continue;
    SUM[i] = A[i] + SUM[i-1];
  }
  int idx=1;
  rep(i, N) {
    if (i==0) continue;
    if (A[i] > 2*SUM[i-1]) {
      idx=1;
    } else idx++;
  }
  cout << idx << "\n";
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

//方針
//前からずっとシミュレーションして、
int main()
{
    long long int n;
    cin >> n;
    long long int a, b;
    a = 1;
    int ans = INT_MAX;
    rep(i, (int)(sqrt(n) + 1))
    {
        if (n % a == 0)
        {
            b = n / a;
            ans = min(ans, max((int)log10(a) + 1, (int)log10(b) + 1));
        }
        a++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
//プログラミングコンテスト用テンプレート
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; scanf("%d",&x);
#define lint(x) long long x; scanf("%lld",&x);
#define vint(v,n) vector<int> v(n); rep(i,n) scanf("%d", &v[i]);
#define vlint(v,n) vector<lint> v(n); rep(i,n) scanf("%lld", &v[i]);
#define double(x) double x; scanf("%lf",&x);
#define vdouble(v,n) vector<double> v(n); rep(i,n) scanf("%lf", &v[i]);
#define string(x) string x; cin >> x;

int main()
{
	string s, result;
	cin >> s;
	for (int i = 0; i < strlen(s.c_str()); i++)
	{
		if (s[i] != 'B')
		{
			result += s[i];
		}
		else if (s[i] == 'B' && strlen(result.c_str()) != 0)
		{
			result.pop_back();
		}
	}

	cout << result << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
typedef pair<int,int> P;
const int MAX_N=400;
const int di[]={1,0,-1,0};
const int dj[]={0,1,0,-1};

bool color[MAX_N][MAX_N];
int H,W;
char ch[MAX_N+1];

void input(){
	cin>>H>>W;
	REP(i,H){
		cin>>ch;
		REP(j,W){
			color[i][j]=(ch[j]=='#');
		}
	}
}
bool isin_(int i,int j){
	return i>=0 && i<H && j>=0 && j<W;
}

bool check_(int i,int j,int d){
	int ni=i+di[d];
	int nj=j+dj[d];
	if(!isin_(ni,nj))return false;
	if(color[i][j]==color[ni][nj])return false;
	return true;
}
bool used[MAX_N][MAX_N];

ll solve(){
	long long ans = 0;
	long long b = 0, w = 0;
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j){
			if(used[i][j]) continue;
			b = 0;
			w = 0;
			queue<P> que;
			used[i][j] = true;
			que.push(P(i, j));
			while(!que.empty()){
				P p = que.front();
				que.pop();
				int ci = p.first, cj = p.second;
				if(color[ci][cj]) b++;
				else w++;
				for(int d = 0; d < 4; ++d){
					if(!check_(ci, cj, d)) continue;
					int ni = ci + di[d], nj = cj + dj[d];
					if(used[ni][nj]) continue;
					used[ni][nj] = true;
					que.push(P(ni, nj));
				}
			}
			ans += b * w;
		}
	}
	return ans;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	input();
	ll ans=solve();
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N = 401;
long long dp[N][N];
long long MAX = 1e18;
long long a[N], n;
long long pre[N];
long long solve(int l, int r)
{
	if(l == r)
		return 0;

	if(dp[l][r] != -1)
		return dp[l][r];
	
	dp[l][r] = MAX;
	for(int i=l;i<r;i++)
		dp[l][r] = min(dp[l][r], solve(l, i) + solve(i+1, r) + pre[r+1]-pre[l]);

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

	for(int i=1;i<=n;i++)
		pre[i] = pre[i-1] + a[i-1];
	cout<<solve(0, n-1);
}

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = (ull)1e9 + 7;

int main(void)
{
	ll n, ma, mb;
	cin >> n >> ma >> mb;
	vector<t3> vs(n);
	rep(i, n) {
		ll a, b, c;
		cin >> a >> b >> c;
		vs[i] = tie(a, b, c);
	}
	const ll INF = 1e15;
	vector<vector<vector<ll>>> dp(2, vector<vector<ll>>(401, vector<ll>(401, INF)));
	dp[0][0][0] = 0;
	rep(i, n) {
		ll a, b, c;
		tie(a, b, c) = vs[i];
		rep(j, 401) {
			rep(k, 401) {
				dp[1][j][k] = dp[0][j][k];
			}
		}
		rep(j, 401-a) {
			rep(k, 401 -b) {
				dp[1][a + j][b + k] = min(dp[1][a+j][b+k], dp[0][j][k] + c);
			}
		}
		swap(dp[0], dp[1]);
	}
	ll mm = INF;
	for (int j = 1; j < 401;j++) {
		for (int k = 1; k < 401; k++) {
			if (j * mb == k * ma) {
				mm = min(mm, dp[0][j][k]);
			}

		}
	}
	if (mm == INF) {
		cout << -1 << endl;
		return 0;
	}
	cout << mm << endl;
	return 0;
}


Measured memory_bytes: 4096