akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A = list(map(int,input().split()))

A.sort(reverse=True)
ans = 0
if N%2==0:
    ans = A[0]
    for i in range(N//2-1):
        ans += 2*A[i+1]
else:
    ans = A[0]
    for i in range(N//2-1):
        ans += 2*A[i+1]
    ans += A[N//2]

print(ans)


Measured memory_bytes: 31532
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 1000000000;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
#define pb push_back 
#define all(c) (c).begin(),(c).end()
int n;
map<int,int> mp;

int main(){
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt", "r", stdin);
	#endif
	cin>>n;
	for(int x,i=0; i<n; ++i){
		scanf("%d",&x);
		++mp[x];
	}
	cin>>n;
	for(int x,i=0; i<n; ++i){
		scanf("%d",&x);
		if(!mp[x]--)
			return cout<<"NO",0;
	}
	cout<<"YES";
}




Measured memory_bytes: 11648
n = [int(c) for c in input()]
template_list = [
    "{}+{}+{}+{}",
    "{}+{}+{}-{}",
    "{}+{}-{}+{}",
    "{}+{}-{}-{}",
    "{}-{}+{}+{}",
    "{}-{}+{}-{}",
    "{}-{}-{}+{}",
    "{}-{}-{}-{}",
]
for template in template_list:
    temp = template.format(*n)
    if eval(temp) == 7:
        ans = "{}=7".format(temp)
        break
print(ans)

Measured memory_bytes: 3060
n,k = map(int,input().split())
d = list(map(int,input().split()))

n_str = str(n)
l = len(n_str)
a = [i for i in range(10) if i not in d]

#同じ桁の時
ans = ""
for i in range(l):
    for j in a:
        if j == int(n_str[i]):
            ans += str(j)
            break
        elif j > int(n_str[i]):
            ans += str(j) + str(a[0])*(l-i-1)
            print(ans)
            exit()

if len(ans)>0:
    if int(ans) >= n:
        print(ans)
        exit()

if 0 in a:
    ans = str(a[1]) + str(a[0])*l
else:
    ans = str(a[0])*(l+1)

print(ans)



Measured memory_bytes: 9180
N,M = map(int,input().split())
PY = []
for i in range(M):
    p,y = map(int,input().split())
    PY.append([p,y,i])
PY.sort()


ans = [0 for i in range(M)]
c = 1
d = 0
for i in range(M):
    
    if c == PY[i][0]:
        d += 1
    else:
        c = PY[i][0]
        d = 1
    ans[PY[i][2]] = '0'*(6-len(str(PY[i][0])))  + str(PY[i][0]) + '0'*(6-len(str(d))) + str(d)
for i in ans:
    print(i)

Measured memory_bytes: 31560
# include<iostream>
# include<cstring>
# include<cstdio>
# include<algorithm>
# define LL long long
# include<queue>
using namespace std;
const int MAX=2e5+1;
int n,k,q,L;
LL ans;
int a[MAX],b[MAX];
int num[MAX][21];
bool use[21];
deque<int> qu;
void work(int a,int x)
{
	for(int i=0;i<20;++i)
	  if(a&(1<<i)) num[x][++num[x][0]]=i;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	  scanf("%d",&a[i]),work(a[i],i);
	for(int i=1;i<=n;++i)
	  {
	  	for(int j=1;j<=num[i][0];++j)
	  	  {
	  	  	if(!use[num[i][j]]) use[num[i][j]]=1;
	  	  	else
	  	  	{
	  	  		while(use[num[i][j]]&&!qu.empty())
	  	  		{
	  	  			int tt=qu.back();
	  	  			qu.pop_back();
	  	  			--L;
	  	  			for(int k=1;k<=num[tt][0];++k)
	  	  			  use[num[tt][k]]=0;
				}
				use[num[i][j]]=1;
			}
		  }
		qu.push_front(i),++L,ans+=L;
	  }
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 17408
#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 calc_digit(ll n) {
  int res = 0;
  while (n) {
    ++res;
    n /= 10;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  int res = (1 << 29);  // 十分大きい値で初期化
  for (ll a = 1; a * a <= n; ++a) {
    if (n % a == 0) {
      ll b = n / a;
      int f = max(calc_digit(a), calc_digit(b));
      res = min(res, f);
    }
  }
  cout << res << endl;
}

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

int main() {
	int n; cin >> n;
	int t[n], x[n], y[n];
	for (int i = 0; i < n; i++)
	{
		cin >> t[i] >> x[i] >> y[i];
	}

	bool ok = true;
	int pret = 0, prex = 0, prey = 0;
	for (int i = 0; i < n; i++)
	{
		int dt = abs(t[i] - pret), dx = abs(x[i] - prex), dy = abs(y[i] - prey);
		if(dt < dx + dy || dt % 2 != (dx + dy) % 2) {
			ok = false;
			break;
		}
		pret = t[i], prex = x[i], prey = y[i];
	}

	if(ok) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 1408
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10 ;
int n , m , q ;
int arr[maxn*maxn] , mat[maxn][maxn] ;
void input() 
{
	cin >> n >> m >> q ;
	for ( int i = 0 ; i< q; i++ )
		cin >> arr[i] ;
}
int main()
{
	input() ;
	int p = 0 ;
	for ( int i = 0 ; i < n ; i++ ) 
	{
		if ( i % 2 ) 
		{
			for  ( int j = 0 ; j < m ; j++ ) 
				if ( arr[p] ) 
					mat[i][j] = p , arr[p]-- ;
				else
					p++ , j-- ;
				
		}
		else
		{
			for ( int j = m-1 ; j >= 0 ; j-- ) 
				if ( arr[p] ) 
					mat[i][j] = p , arr[p]-- ;
				else
					p++ , j++ ; 
		}
	}
	for ( int i = 0 ; i < n ; cout << endl , i++ ) 
		for ( int j = 0 ; j < m ; j++ )
			cout << mat[i][j] +1 << " " ;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int D; //365
    cin >> D;

    int c[26];
    rep(i, 0, 26) {
        cin >> c[i];
    }

    int s[D][26];
    int t[D] = {};
    //各日について、s[i][j]が最大になるコンテストタイプで初期化
    rep(i, 0, D) {
        int mx = -1;
        rep(j, 0, 26) {
            cin >> s[i][j];
            if (mx < s[i][j]) {
                mx = s[i][j];
                t[i] = j;
            }
        }
    }

    //日程を乱数で初期化
    srand(time(NULL));
    /*rep(i, 0, D) {
        t[i] = rand() % 26;
    }*/

    ll mx_score = -1e18;
    int cnt = 110000;
    while (cnt--) {
        //d日目のコンテストをqに置き換えてスコアを計算し、改善しなければ元に戻す
        int d = rand() % 365;
        int q = rand() % 26;
        int old = t[d];
        t[d] = q;

        //スコアを計算する
        ll score[D] = {};
        vector<int> last_day(26, -1);
        rep(i, 0, D) {
            if (i != 0) score[i] = score[i - 1];
            //増加分
            score[i] += s[i][t[i]];

            last_day[t[i]] = i;

            //減少分
            ll decrease = 0;
            rep(j, 0, 26) {
                decrease += c[j] * (i - last_day[j]);
            }
            score[i] -= decrease;
        }
        //cout << "score[D - 1]: " << score[D - 1] << endl;
        if (mx_score > score[D - 1]) {
            t[d] = old;
        } else {
            mx_score = score[D - 1];
        }
    }

    rep(i, 0, D) cout << t[i] + 1 << endl;
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<ll, ll>  pii;
typedef pair<ld, ld>  pld;
typedef long double ld;
ll n;
vector<pll> v;
ld dis(pll a, pll b){
    return sqrt((a.ff-b.ff)*(a.ff-b.ff)+(a.ss-b.ss)*(a.ss-b.ss));
}
ld calc(){
    ld ret = 0;
    for(int i = 0; i < v.size()-1; ++i){
        ret += dis(v[i], v[i+1]);
    }
    return ret;
}
ld ans;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for(int i = 0; i < n; ++i){
        ll a, b;
        cin >> a >> b;
        v.pb({a, b});
    }
    sort(v.begin(), v.end());
    ld fact = 1;
    ans += calc();
    while(next_permutation(v.begin(), v.end())){
        ++fact;
        ans += calc();
    }
    ans = ans/fact;
    cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-14;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll a, b, c; cin >> a >> b >> c;
    if(c-a-b<0)cout<<"No\n";
    else if(4*a*b<(c-a-b)*(c-a-b))cout<<"Yes\n";
    else cout<<"No\n";
}


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

using namespace std;

#define F first
#define S second
#define modulo ll (1e9 + 7)

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

void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

const int N = 2005, M = 26, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main(){
    init();

    int w, a, b;    cin >> w >> a >> b;
    if(max(a, b) <= min(a + w, b + w))  return cout << 0, 0;
    if(b - (a + w) >= 0)  cout << b - (a + w);
    else cout << a - (b + w);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

bool G[80001]={};

int main(){
	
	for(int i=3;i<80000;i+=2){G[i]=true;
		for(int j=3;j*j<=i;j++)
			if(i%j==0){G[i]=false;break;}
	}
	G[2]=true;
	int N;
	while(cin>>N){
	
		for(int i=N-1;i>0;i--)
			if(G[i]==true){cout<<i;
		break;
		}
		cout<<" ";
		for(int i=N+1;i<80000;i++)
			if(G[i]==true){cout<<i<<endl;
		break;
		}
	}
	return 0;
}

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

using namespace std;

const int N = 1e5 + 5, M = 20;
bool mark[N];
int cnt[N];
vector<int> g[N];
vector<pair<int, int>> E;
map<int, int> id[N];

int st[N], en[N], timer;
int par[N][M];
void pfs(int u, int p) {
  par[u][0] = (p == -1 ? u : p);
  for (int i = 1; i < M; i++) {
    par[u][i] = par[par[u][i - 1]][i - 1];
  }
  mark[u] = true;
  st[u] = timer++;
  for (int v : g[u]) {
    if (!mark[v]) {
      pfs(v, u);
    }
  }
  en[u] = timer;
}

bool is_anc(int u, int v) {
  return st[u] <= st[v] && en[u] >= en[v];
}

int lca(int u, int v) {
  if (is_anc(u, v)) {
    return u;
  }
  if (is_anc(v, u)) {
    return v;
  }
  for (int i = M - 1; ~i; i--) {
    if (!is_anc(par[u][i], v)) {
      u = par[u][i];
    }
  }
  return par[u][0];
}

int lazy[N];
int lfs(int u, int p) {
  mark[u] = true;
  for (int v : g[u]) {
    if (!mark[v]) {
      lazy[u] += lfs(v, u);
    }
  }
  assert(lazy[u] >= 0);
  if (p != -1 && lazy[u] % 2) {
    id[u][p] = 1;
    id[p][u] = 1;
  }
  return lazy[u];
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  if (m & 1) {
    cout << -1 << '\n';
    return 0;
  }
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    E.emplace_back(u, v);
    g[u].push_back(v);
    g[v].push_back(u);
    ++cnt[u];
  }
  pfs(0, -1);
  vector<int> nxt;
  for (int i = 0; i < n; i++) {
    if (cnt[i] & 1) {
      nxt.push_back(i);
    }
  }
  assert(nxt.size() % 2 == 0);
  for (int i = 0; i < nxt.size(); i += 2) {
    ++lazy[nxt[i]];
    ++lazy[nxt[i + 1]];
    ----lazy[lca(nxt[i], nxt[i + 1])];
  }
  memset(mark, false, sizeof mark);
  lfs(0, -1);
  for (auto e : E) {
    if (id[e.first][e.second]) {
      cout << e.second + 1 << ' ' << e.first + 1 << '\n';
    } else {
      cout << e.first + 1 << ' ' << e.second + 1 << '\n';
    }
  }
  return 0;
}


Measured memory_bytes: 36852
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static string Solve(Scanner scan) {
        int N = scan.NextInt(), M = scan.NextInt();
        var ac = 0;
        var wa = 0;
        var Q = new (int WAcount, bool isAC)[N];
        for (int i = 0; i < M; i++) {
            var p = scan.NextInt();
            var S = scan.Next();
            if (Q[p - 1].isAC) continue;
            if (S == "AC") {
                Q[p - 1].isAC = true;
                ac++;
                wa += Q[p - 1].WAcount;
            }
            else Q[p - 1].WAcount++;
        }
        return $"{ac} {wa}";
    }
}

class Scanner
{
    string[] s;
    int i;
    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public int NextInt() => int.Parse(Next());
}

Measured memory_bytes: 42056
#include<bits/stdc++.h>
 
#define ll long long int
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define INF 0x3f3f3f3f
#define show(x) cerr<<#x<<" : "<<x<<'\n';
#define yogeshk972() cerr<<"\nTime Taken : "<<(float)(clock()-time_p)/CLOCKS_PER_SEC<<"\n";
clock_t time_p=clock();
 
using namespace std;
const int N=2e3+1, mod= 1e9+7;

int main(){
	ios_base::sync_with_stdio(0);	cin.tie(0);
	
	int n;
	cin>>n;
	for(int i=1;i<=9;i++){
		if( n%i==0 && n/i<10 ){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
    yogeshk972();
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    vector<ll> red(A), green(B), none(C);
    rep(i, A) cin >> red[i];
    rep(i, B) cin >> green[i];
    rep(i, C) cin >> none[i];
    sort(red.rbegin(), red.rend());
    sort(green.rbegin(), green.rend());

    vector<ll> candidate;
    rep(i, X) candidate.push_back(red[i]);
    rep(i, Y) candidate.push_back(green[i]);
    rep(i, C) candidate.push_back(none[i]);
    sort(candidate.rbegin(), candidate.rend());

    ll ans = 0;
    rep(i, X + Y) ans += candidate[i];
    cout << ans << endl;
}


Measured memory_bytes: 9736
//
//  main.cpp
//  TP1_2-C
//
//  Created by Saicj on 2015/07/13.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, const char * argv[])
{

    int a,b,c;
    
    std::cin >> a >> b >> c;
    
//    int numList[] = {a,b,c};
//    std::vector<int> myVector (numList, numList + 3);
//     std::vector<int>::iterator it;
//    
//    sort (myVector.begin(), myVector.begin()+3);
//    
//    
//    for (it=myVector.begin(); it!=myVector.end(); ++it)
//        std::cout << " " << *it;
//    
//     std::cout << "\n";

    if (a > b) {
        int temp = a;
        a = b;
        b = temp;
    }
    
    if (b > c){
        
        int temp = b;
        b = c;
        c= temp;
    }
    
    if (a > b) {
        int temp = a;
        a = b;
        b = temp;
    }
    
    std::cout << a <<" " <<b <<" " <<c << "\n";
    
    return 0;
}

Measured memory_bytes: 1164
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
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);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	vi p(a);
	vi q(b);
	vi r(c);
	for(int i=0;i<a;i++)	cin>>p[i];
	for(int i=0;i<b;i++)	cin>>q[i];
	for(int i=0;i<c;i++)	cin>>r[i];
	sort(p.begin(),p.end(),greater<int>());
	sort(q.begin(),q.end(),greater<int>());
	sort(r.begin(),r.end(),greater<int>());
	vi res;
	for(int i=0;i<x;i++)
		res.pb(p[i]);
	for(int i=0;i<y;i++)
		res.pb(q[i]);
	sort(res.begin(),res.end());
	int i=0;
	while(i<res.size() && i<r.size() && res[i]<r[i])
	{
		swap(res[i],r[i]);
		i++;
	}
	int sum=0;
	for(int i=0;i<res.size();i++)
		sum+=res[i];
	cout<<sum<<endl;
}












Measured memory_bytes: 4852
//
// Created by 杉浦光紀 on 2019-03-27.
//

#include <iostream>
#include <string>

using namespace std;

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

    int ans = 0;
    int tmp = 0;

    for (int i = 0; i < input.size(); ++i) {
        if (input[i] == 'A' || input[i] == 'T' || input[i] == 'C' || input[i] == 'G') {
            tmp++;
            if (ans < tmp) {
                ans = tmp;
            }
        } else {
            tmp = 0;
        }
    }

    cout << ans;
}

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

int main() {
	int n; cin >> n;
	vector<int>x(n), y; for (auto&& i : x)cin >> i;
	y = x;
	sort(y.rbegin(), y.rend());
	int L = y[n / 2 - 1], R = y[n / 2];
	for (int i = 0; i < n; i++) {
		if (x[i] >= L)cout << R << endl;
		else cout << L << endl;
	}

	return 0;
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

int n;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n; cout << (n + 1) / 2;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

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

#define MAX 100000
#define NIL -1

struct node{
  int parent,left,right;
};

struct node T[MAX];
int n, D[MAX], H[MAX];

void setdepth(int, int);
int setheight(int);
int getsibling(int);
void print(int);


int main(){
  int i, v, l, r;
  int root = 0;
  scanf("%d",&n);

  for(i=0;i<n;i++){
    T[i].parent = NIL;
  }

  for(i=0;i<n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if(l!=NIL) T[l].parent = v;
    if(r!=NIL) T[r].parent = v;
  }

  for(i=0;i<n;i++) {
    if(T[i].parent==NIL) root = i;
  }

  setdepth(root,0);
  setheight(root);

  for(i=0;i<n;i++) print(i);

  return 0;
}

void setdepth(int u, int d){
  if(u==NIL) return;
  D[u] = d;
  setdepth(T[u].left,d+1);
  setdepth(T[u].right,d+1);
}

int setheight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].left!=NIL) h1 = setheight(T[u].left) + 1;
  if(T[u].right!=NIL) h2 = setheight(T[u].right) + 1;
  return H[u] = (h1>h2 ? h1:h2);
}

int getsibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=u && T[T[u].parent].left!=NIL) return T[T[u].parent].left;
  if(T[T[u].parent].right!=u && T[T[u].parent].right!=NIL) return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg = 0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent==NIL) {
    printf("root\n");
  }
  else if(T[u].left==NIL && T[u].right==NIL) {
    printf("leaf\n");
  }
  else printf("internal node\n");
}



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

static constexpr int MAX = 100000000;

int search(int price, std::vector<int> &numbers, const std::vector<int>& coins) {
    if (price < 1) {
        return MAX;
    }
    if (numbers[price] != -1) {
        return numbers[price];
    }

    for (auto c : coins) {
        int val = search(price - c, numbers, coins);
        if (numbers[price] == -1 || val + 1 < numbers[price]) {
            numbers[price] = val + 1;
        }
    }
    return numbers[price];
}


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

    std::vector<int> coins(m);
    std::vector<int> numbers(n + 1, -1);

    for (int i = 0; i < m; i++){
        std::cin >> coins[i];
        numbers[coins[i]] = 1;
    }

    int val = search(n, numbers, coins);
    std::cout << val <<std::endl;
}



Measured memory_bytes: 6216
S = list(input())
L = [0]*2019
L[0]=1
digit = 1
x = 0

for i in S[::-1]:
    x += digit*int(i)
    digit *= 10
    x %= 2019
    digit %= 2019 
    L[x] += 1

ans = 0

for i in L:
    ans += i*(i-1)//2

print(ans)

Measured memory_bytes: 11764
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV], memo[1001][10001];
PII ax[MV];

ll xd(int n, int h)
{
	if(h <= 0)
	return 0;
	else if(!n)
	return MOD;
	if(memo[n][h] != -1)
	return memo[n][h];
	ll rx = min(xd(n-1, h), ax[n].ss + xd(n, h-ax[n].ff));
	memo[n][h] = rx;
	return rx;	
}

void solve(int T)
{
	memset(memo, -1, sizeof(memo));
	int n,h;
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	cin>>ax[i].ff>>ax[i].ss;
	ll res = xd(n, h);
	cout<<res<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

// #ifndef ONLINE_JUDGE
// 	time_t time_t1, time_t2;
// 	time_t1 = clock();
// #endif

	while(T--)
	solve(T);

// #ifndef ONLINE_JUDGE
// 	time_t2 = clock();
// 	SETF();
// 	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
// 	UNSETF();
// #endif

	return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define REP(i,a) for(int i=0;i<(a);i++)
#define REPR(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
// using ll = long long;
// using vi = vector<int>;
// using vvi = vector<vi>;
// using vl = vector<long long>;
// using vvl = vector<vl>;
// using vs = vector<string>;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int main () {
  int N = si();
  std::vector<int> H(N);
  int max=0,num=0;
  for (size_t i = 0; i < N; i++) {
    cin >> H[i];
    if(max <= H[i]) {
      max =  H[i];
      num++;
    }
  }
  cout << num << endl;
}


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

const ll INF = 1e9;

int main(){
    int N,MA,MB; cin >> N >> MA >> MB;
    int ma=0,mb=0;
    vector<ll> A(N),B(N),C(N);
    rep(i,N){
        int a,b,c; cin >> a >> b >> c;
        A[i] = a; B[i] = b; C[i] = c;
        ma = max(ma, a); mb = max(mb, b);
    }
    ll dp[N+1][ma*(N+1)][mb*(N+1)];
    rep(i,N+1)rep(j,ma*(N+1))rep(k,mb*(N+1)){
        if(j==0 && k==0) dp[i][j][k] = 0;
        else dp[i][j][k] = INF;
    }
    
    for(int i=1;i<=N;i++){
        for(int j=0;j<=ma*N;j++){
            for(int k=0;k<=mb*N;k++){
                if(j-A[i-1] >= 0 && k-B[i-1] >= 0){
                    dp[i][j][k] = min(dp[i][j][k], dp[i-1][j-A[i-1]][k-B[i-1]] + C[i-1]);
                }
                dp[i][j][k] = min(dp[i][j][k], dp[i-1][j][k]);
            }
        }
    }
    ll res = INF;
    for(int i=1;i<=N;i++){
        res = min(res, dp[N][MA*i][MB*i]);
    }
    if(res==INF){
        cout << -1 << endl;
        return 0;
    }
    cout << res << endl;
}

Measured memory_bytes: 57384
#include<bits/stdc++.h>
using namespace std;
void READ() {
 #ifndef ONLINE_JUDGE
   freopen("./Input.in", "r", stdin);
  #endif
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //READ();
    int n;
    long long m;
    cin >> n >> m;


    set<long long>div;

    for(int i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            div.insert(i);
            div.insert(m / i);
        }
    }

    // long long max_search = floor(m * 1.0 / n);
    long long sol = 1;
    for(auto &c : div) {
        long long cc = m / c;
        if (cc >= n) {
            sol = c;
        }
    }

    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
d=list(map(int,input().split()))
d=sorted(d)
m=int(input())
t=list(map(int,input().split()))
t=sorted(t)
flag=True 
if n<m:
    flag=False
else:
    t_num=[] #tの数字の内訳
    bef=t[0]
    ren=1
    for i in range(1,m):
        if bef!=t[i]:
            t_num.append([bef,ren])
            bef=t[i]
            ren=1
        else:
            ren+=1
    t_num.append([bef,ren])
    kind=len(t_num)
    
    
    now=0
    ren=0
    for i in range(n):
        if t_num[now][0]==d[i]:
            ren+=1
        else: 
            if ren!=0: #カウントしてる途中で切り替わる
                if t_num[now][1]<=ren:
                    now+=1
                    ren=0
                    if kind==now: #ok
                        break
                    if t_num[now][0]==d[i]:
                        ren+=1
                else:
                    flag=False
                    break
        #print(ren)
        #print(t_num[now][0])
    if ren!=0: #カウントしてる途中で終わる
        if t_num[now][1]<=ren:
            now+=1
    if now<kind: #ng
        flag=False
print("YES" if flag else "NO")

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

int main(){
  long long a,b;
  cin >> a >> b;
  if(a==1 || b==1){
    cout << 1;
    return 0;
  }
  long long ans = a*b;
  if(ans%2==0) cout << ans/2;
  else cout << ans/2 +1;
}

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

int main(){
	int num[8];
	int n, number;
	int min = 0, max = 0;
	
	cin >> n;
	for(int c = 0; c < n; c++){
		min = max = 0;
		cin >> number;
		for(int i = 7; i >= 0; i--){
			num[i] = number % 10;
			number /= 10;
		}
	
		sort(num, num+8);
		for(int i = 0, j = 10000000; i < 8; i++){
			min += num[i] * j;
			j /= 10;
		}
		for(int i = 7, j = 10000000; i >= 0; i--){
			max += num[i] * j;
			j /= 10;
		}
	
		cout << max - min << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};

int main(){
    int N,M; cin >> N >> M;
    bool e[100000];
    pair<int,int> pp[100000];
    for(int i=0;i<M;i++){
        int a,b; cin >> a >> b;
        pp[i] = make_pair(b,a);
    }
    for(int i=0;i<N;i++){
        e[i]=true;
    }
    int cnt=0;
    sort(pp,pp+M);
    int tmp=-1;
    for(int i=0;i<M;i++){
        int a=pp[i].second-1; int b=pp[i].first-1;
        cerr << a << " " << b << " ";
        bool f=false;
        if(!(a<=tmp && tmp<=b)){
            f=true;
        }
        if(f){ //破壊
            e[b-1]=false;
            cnt++;
            tmp=b-1;
        }
        cerr << f << endl;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 1024
/*input
4
ushi
tapu
nichia
kun

*/
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
int mpow(int base, int exp); 
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;cin>>s;
    for(int i=0;i<s.size();i++)
    cout<<"x";
	cout<<endl;
    //cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N; cin >> N;
    ves s(N);
    rep(i,N) cin >> s[i];
    int M; cin >> M;
    ves t(M); 
    rep(i,M) cin >> t[i];

    int ans = 0;
    rep(i,N) {
        int temp = 0;
        rep(j,N) if(s[i] == s[j]) temp++;
        rep(j,M) if(s[i] == t[j]) temp--;
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**9)

N, K = map(int, input().split())
A = [0] + list(map(int, input().split()))

stack = []
s = set()
def dfs(a, k):
  stack.append(a)
  s.add(a)
  if k == K:
    return a
  next_a = A[a]
  if next_a in s:
    idx = stack.index(next_a)
    i = (K - (k + 1)) % (k + 1 - idx)
    return stack[idx + i]
  else:
    res = dfs(next_a, k+1)
  return res

print(dfs(1, 0))

Measured memory_bytes: 168368
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int X, N;
    cin >> X >> N;
    vector<bool> Pexists(102, false);
    rep(i, N) {
        int p;
        cin >> p;
        Pexists[p] = true;
    }

    int ans = -1;
    rep(p, 102) {
        if (!Pexists[p] && abs(p - X) < abs(ans - X)) ans = p;
    }

    write(ans);
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
#include <cstdlib> //絶対値 abs()
#include <iomanip>
#include <queue>
using namespace std;

int main(){
  int n,m;
  cin >> n >> m;
  int a, b;

  vector<int> depth(n,-1);
  vector<vector<int>> tree(n,vector<int>(0));
  vector<int> path(n);
  for(int i=0; i<m; i++){
    cin >> a >> b;
    a--; b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  
  queue<int> que;
  que.push(0);
  depth[0] = 0;
  
  while(!que.empty()){
    int v = que.front();
    que.pop();
    
    for(int k : tree[v]){
      if(depth[k] != -1) continue;
      depth[k] = depth[v] + 1;
      path[k] = v; 
      que.push(k);
    }
  }
  bool bl = true;
  for(int i=0; i<n; i++){
    if(depth[i] == -1){
      bl = false;
      break;
    }
  }
  if(bl){
    cout << "Yes" << endl;
    for(int i=1; i<n; i++){
      cout << path[i] + 1 << endl;
    }
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 10564
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;
int tim[111];
int ve[111];
int maxi[111];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)scanf("%d", &tim[i]);
	for (int i = 0; i < num; i++)scanf("%d", &ve[i]);
	int now = 0;
	maxi[0] = 0;
	for (int i = 0; i < num; i++)
	{
		now = min(now + tim[i], ve[i]);
		maxi[i + 1] = now;
	}
	now = 0;
	maxi[num] = 0;
	for (int i = num - 1; i >= 0; i--)
	{
		now = min(now + tim[i], ve[i]);
		maxi[i] = min(maxi[i], now);
	}
	double ans = 0;
	for (int i = 0; i < num; i++)
	{
		double z = (double)(tim[i] - (abs(maxi[i] - maxi[i + 1]))) / 2.0 + max(maxi[i], maxi[i + 1]);
		double m = (maxi[i] + z)*(z - maxi[i]) / 2 + (maxi[i + 1] + z)*(z - maxi[i + 1]) / 2;
		if (z < ve[i])ans += m;
		else ans += m - (z - ve[i])*(z - ve[i]);
	}
	printf("%lf\n", ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n,m;
    cin >> n >> m;
    string a,b;
    for(int i=0; i<n; i++) a += char(m+'0');
    for(int i=0; i<m; i++) b += char(n+'0');
    if(a <= b) cout << a;
    else cout << b;
}

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;

ll dp[13]; //後ろからdケタ目までみたときに、mod 13 で k であるものの数

const int mod = 1000000007;

int main() 
{
    string s;
    cin >> s;
    rep(i,13) dp[i] = 0;
    dp[0] = 1;

    int m = 1;
    for (int i=0; i<s.size();i++) {
        ll nextDp[13];
        rep(j,13) nextDp[j] = 0;
        int d = s.size()-i-1;
        if (s[d] == '?') {
            rep(j,10) {
                rep(k,13) {
                    nextDp[(k + m * j) % 13] += (dp[k] % mod);
                    nextDp[(k + m * j) % 13] %= mod;
                }
            }
        } else {
            int c  = s[d] - '0';
            rep(k,13) {
                nextDp[(k + m * c) % 13] += dp[k] % mod;
                nextDp[(k + m * c) % 13] %= mod;
            }
        }
        m *= 10;
        m %= 13;
        rep(i,13) dp[i] = nextDp[i];
    }

    cout << dp[5] << endl;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

VEC(string) Grid(int A, char white, char black)
{
    const int WIDTH = 100;
    VEC(string) Ret;
    while (A > 0) {
        Ret.PB(string(WIDTH, black));
        Ret.PB(string(WIDTH, black));
        Ret.PB(string(WIDTH, black));

        int r = SZ(Ret) - 2, c = 1;
        while (A > 0 && c < WIDTH) {
            Ret[r][c] = white;
            A--;
            c += 3;
        }
    }

    while (!Ret.empty() && Ret.back() == string(WIDTH, black))
        Ret.pop_back();

    while (SZ(Ret) < 3 || Ret.back() != string(WIDTH, black))
        Ret.PB(string(WIDTH, black));
    return Ret;
};

void solveSingleCase(int caseNo)
{
    int A, B;
    cin >> A >> B;
    // A white, B black components are needed.
    VEC(string) Grid1 = Grid(A - 1, '.', '#');
    VEC(string) Grid2 = Grid(B - 1, '#', '.');
    cout << SZ(Grid1) + SZ(Grid2) << " " << 100 << endl;
    for (string row : Grid1)
        cout << row << endl;
    for (string row : Grid2)
        cout << row << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};

Measured memory_bytes: 256
/*
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
int main(){
	double ans;
	ll n,A,B,C,D,flag;
	cin>>n>>A>>B>>C>>D;
	if(D*n >= ) flag = 1;
	if(flag) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}
*/
#include<iostream> 
#include<cstdio> 
#include<cstring> 
#include<cmath> 
#include<vector> 
#include<algorithm> 
#define N 10005 
#define LL long long 
#define inf 1<<29 
#define eps 1e-7 
using namespace std; 
vector<int>v[100005]; 
int get_sg(int u,int pre){ 
    int ret=0; 
    for(int i=0;i<v[u].size();i++){ 
        if(v[u][i]!=pre) 
            ret^=(1+get_sg(v[u][i],u)); 
    } 
    return ret; 
} 
int main(){ 
    int t,n; 
  
	scanf("%d",&n); 
    for(int i=1;i<=n;i++) 
          v[i].clear(); 
    for(int i=1;i<n;i++){ 
           int x,y; 
           scanf("%d%d",&x,&y); 
            v[x].push_back(y); 
            v[y].push_back(x); 
        } 
        if(get_sg(1,-1)) 
            puts("Alice"); 
        else 
            puts("Bob"); 
    return 0; 
} 

Measured memory_bytes: 11904
#include <bits/stdc++.h>
#define ll int
#define N 100000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;
/**
        * @author :: Sawlani
        *
        */

int main()
{
  //freopen("input.txt", "r", stdin);
   
   ll h,n;
   cin >>  h >> n;


ll ans=0;
   f(i,1,n){
           ll x;
           cin >> x;
           ans+=x;
   }

   if(ans>=h)
   cout << "Yes" ;
   else
   {
           cout << "No";
   }
   
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

int main(void){

int n,d;

scanf("%d %d",&n,&d);

int i,count=0;

int x[n],y[n];

double dis[n];

for(i=0;i<n;i++){
  scanf("%d %d",&x[i],&y[i]);

dis[i]=(double)sqrt((double)pow(x[i],2)+(double)pow(y[i],2));

}

for(i=0;i<n;i++){
  if(dis[i]<=d){count++;}
}

printf("%d",count);

return 0;
}

Measured memory_bytes: 5272
h,w = map(int,input().split())
a = [input() for i in range(h)]
ok = True
l = [False]*w
for i in range(h):
    d = False
    for j in range(w):
        if a[i][j]=='#':
            if i<h-1 and a[i+1][j]=='#':
                if d:ok=False
                d = True
            else:
                if l[j]: ok=False
                l[j] = True
print('Possible' if ok else 'Impossible')

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

struct P
{
    int x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v[1],v1;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[111];
long long l[111][113111];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s[222][22];
//priority_queue<P> q;
queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

//string r,r1;
//char r[2];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;

}


long long f(int i,int n,int m)
{
    if(n<=0) return l[i][m];
    return (l[i][m]-l[i][n-1]+mod)%mod;
}

int main()
{
    scanf("%d %d",&a,&b);
    for(int t=1;t<=a;t++)
        scanf("%d",&o[t]);
    l[0][0]=1;
    for(int t=0;t<=b;t++)
        l[0][t]=1;
    for(int t=1;t<=a;t++)
    {
        l[t][0]=1;

        for(int w=1;w<=b;w++)
        {


            l[t][w]+=f(t-1,w-o[t],w)+l[t][w-1],l[t][w]%=mod;
        //printf("%lld ",l[t][w]);
        }
    }
    printf("%lld",f(a,b,b));
}





Measured memory_bytes: 90112