akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main(){
  map<string, int> cards;
  int n, m;
  cin >> n;
  for (int i=0;i<n;i++) {
    string s;
    cin >> s;
    if (cards.find(s)==cards.end()) {
      cards[s] = 0;
    }
    cards[s]++;
  }
  cin >> m;
  for (int i=0;i<m;i++) {
    string s;
    cin >> s;
    if (cards.find(s)==cards.end()) {
      cards[s] = 0;
    }
    cards[s]--;
  }
  int tot_max = 0;
  for (auto it=cards.begin();it!=cards.end();it++) {
    if (tot_max < it->second) {
      tot_max = it->second;
    }
  }
  cout << tot_max << endl;
  return 0;
}


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

signed main(void)
{
	int n, ans, sum, cnt; cin >> n;
	int f[n][10];
	int p[n][11];

	rep(i, n) rep(j, 10) cin >> f[i][j];
	rep(i, n) rep(j, 11) cin >> p[i][j];
	ans = (int) -1e9;
	for(int bit = 1; bit < (1 << 10); bit++)
	{
		int plan[10];
		for(int i = 0; i < 10; i++)
		{
			if (bit & (1 << i))
			{
				plan[i] = 1;
			}
			else
				plan[i] = 0;
		}
		sum = 0;
		rep(j, n)
		{
			cnt = 0;
			rep(i, 10)
			{
				if (plan[i] & f[j][i])
					cnt++; 
			}
			sum += p[j][cnt];
		}
		ans = max(ans, sum);
	}
	cout <<  ans << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import deque
S = deque(input())
Q = int(input())

reverse = False
for _ in range(Q):
    query = input().split()
    if query[0] == "1":
        reverse = not reverse
    else:
        tail = bool(int(query[1]) - 1) ^ reverse
        c = query[2]
        if tail:
            S.append(c)
        else:
            S.appendleft(c)

print("".join(reversed(S)) if reverse else "".join(S))


Measured memory_bytes: 8436
n, k = map(int, input().split())
tel = list(map(int, input().split()))
pos = tel[0]
ls = [pos]
for i in range(len(tel)*2):
    pos = tel[pos - 1]
    ls.append(pos)
if k < len(tel) * 2:
    print(ls[k - 1])
else:
    patarn = ls[-len(set(ls[-len(tel):])):]
    destination = patarn[((k-len(ls)) % len(patarn)) - 1]
    print(destination)


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

mod=998244353

N=int(input())
M1=int(input())
E1=[[] for i in range(N+1)]
for i in range(M1):
    x,y=map(int,input().split())
    E1[x].append(y)
    E1[y].append(x)

M2=int(input())
E2=[[] for i in range(N+1)]
for i in range(M2):
    x,y=map(int,input().split())
    E2[x].append(y)
    E2[y].append(x)

M3=int(input())
E3=[[] for i in range(N+1)]
for i in range(M3):
    x,y=map(int,input().split())
    E3[x].append(y)
    E3[y].append(x)

G1=[-1]*(N+1)
G1[N]=0
for i in range(N-1,-1,-1):
    GS=set()
    for to in E1[i]:
        GS.add(G1[to])
    for j in range(N+1):
        if j in GS:
            continue
        else:
            G1[i]=j
            break

G2=[-1]*(N+1)
G2[N]=0
for i in range(N-1,-1,-1):
    GS=set()
    for to in E2[i]:
        GS.add(G2[to])
    for j in range(N+1):
        if j in GS:
            continue
        else:
            G2[i]=j
            break

G3=[-1]*(N+1)
G3[N]=0
for i in range(N-1,-1,-1):
    GS=set()
    for to in E3[i]:
        GS.add(G3[to])
    for j in range(N+1):
        if j in GS:
            continue
        else:
            G3[i]=j
            break

from collections import Counter
C1=Counter()
C2=Counter()
C3=Counter()

for i in range(1,N+1):
    C1[G1[i]]=(C1[G1[i]]+pow(10,18*i,mod))%mod
    C2[G2[i]]=(C2[G2[i]]+pow(10,18*i,mod))%mod
    C3[G3[i]]=(C3[G3[i]]+pow(10,18*i,mod))%mod
        
C12=Counter()

for c1 in C1:
    for c2 in C2:
        C12[c1^c2]=(C12[c1^c2]+C1[c1]*C2[c2])%mod

ANS=0
for c3 in C3:
    ANS=(ANS+C3[c3]*C12[c3])%mod

print(ANS)

Measured memory_bytes: 87140
#include <bits/stdc++.h>
using namespace std; 
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
char arr[n][n];
char arr1[m][m];
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);
    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int z=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        z++;
                }
            }
            if(z==(m*m))
            {
                printf("Yes\n");
                return 0;
            }
        }
    }
    printf("No\n");
}

Measured memory_bytes: 256
#pragma GCC optimize("unroll-loops,Ofast")
#pragma GCC target("avx,sse,sse2,ssse3,tune=native")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ld = long double;
const int maxn = 3030, mod = 1e9 + 7;
int n, m, jump[maxn], nxt[2][maxn][maxn], dp[maxn][maxn][2];
string s;
void add(int &a, int b) {
	a += b;
	if(a >= mod) a -= mod;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> m >> s;
	for(int i = 0; i < n; i++) jump[i] = i;
	for(int l, r, i = 0; i < m; i++) {
		cin >> l >> r; --l, --r;
		jump[l] = max(jump[l], r);
	}
	for(int i = 1; i < n; i++) jump[i] = max(jump[i], jump[i-1]);
	memset(nxt, 0x3f, sizeof nxt);
	for(int c = 0; c < 2; c++)
	for(int i = n; i--;) {
		if(s[i] == char('0'+c)) nxt[c][i][0] = i;
		else nxt[c][i][0] = nxt[c][i+1][0];
		for(int j = 1; j < n; j++) {
			nxt[c][i][j] = nxt[c][i+1][j-(s[i]==char('0'+c))];
		}
	}
	dp[0][0][0] = 1;
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int p = 0; p < 2; p++) {
				int cur = s[i]-'0';
				int ni = i+1;
				int nj = j;
				if(cur == p && nj)
					nj--, cur ^= 1;
				add(dp[ni][nj][p], dp[i][j][p]);
				if(nxt[cur^1][i][j] <= jump[i])
					add(dp[ni][nj+1][cur^1], dp[i][j][p]);
			}
		}
	}
	add(dp[n][0][0], dp[n][0][1]);
	cout << dp[n][0][0];
}


Measured memory_bytes: 143744
import sys
sys.setrecursionlimit(10**7)

n = int(input())
l = [[] for _ in range(n)]
for _ in range(n-1):
  a, b, c = map(int, input().split())
  l[a-1].append([b-1, c])
  l[b-1].append([a-1, c])
q, k = map(int, input().split())
dist = [-1]*n
dist[k-1] = 0
def dfs(v):
  for nv, c in l[v]:
    if dist[nv] == -1:
      dist[nv] = dist[v]+c
      dfs(nv)
dfs(k-1)
for _ in range(q):
  x, y = map(int, input().split())
  print(dist[x-1] + dist[y-1])

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n, k; std::cin >> n >> k;
  int ans = 0;
  rep(i, n) {
    if (i == 0) ans = k;
    else ans *= k-1;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
function Main(input) {
    var r = parseInt(input[0], 10);
    var D = parseInt(input[1], 10);
    var x2000 = parseInt(input[2], 10);

    var xi = r * x2000 - D; // 2001がまず入る

    for (var i = 1; i <= 10; i++) {
        if (i === 1) {
            console.log(xi);
        } else {
            xi = r * xi - D;
            console.log(xi);
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n|\s/));

Measured memory_bytes: 21320
K = int(input())

def B(m,n):
  A = []
  if n == 1:
    A.append(str(m))
  else:
    if m == 0:
      for i in range(0,2,1):
        for j in B(i,n-1):
          A.append(str(0) + j)
    elif m == 9:
      for i in range(8,10,1):
        for j in B(i,n-1):
          A.append(str(9) + j)
    else:
      for i in range(m-1,m+2,1):
        for j in B(i,n-1):
          A.append(str(m) + j)
  return A

C = []
for j in range(1,11,1):
  for i in range(1,10,1):
    C += B(i,j)

print(int(C[K-1]))

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

using namespace std;

template< typename T >
struct WeightedGraph
{
  struct edge
  {
    int to;
    T cost;
  };

  vector< vector< edge > > g;

  WeightedGraph() {}

  WeightedGraph(int n) : g(n) {}

  void add_edge(int u, int v, T cost)
  {
    g[u].emplace_back((edge) {v, cost});
  }

  vector< edge > &operator[](int k)
  {
    return g[k];
  }

  size_t size() const
  {
    return g.size();
  }
};

template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s)
{
  const auto INF = numeric_limits< T >::max();
  vector< T > dist;
  dist.assign(g.size(), INF);

  using Pi = pair< T, int >;
  priority_queue< Pi, vector< Pi >, greater< Pi > > que;
  dist[s] = 0;
  que.emplace(dist[s], s);
  while(!que.empty()) {
    T cost;
    int idx;
    tie(cost, idx) = que.top();
    que.pop();
    if(dist[idx] < cost) continue;
    for(auto &e : g[idx]) {
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      que.emplace(dist[e.to], e.to);
    }
  }
  return dist;
}

int main()
{
  int V, E, S;
  scanf("%d %d %d", &V, &E, &S);
  WeightedGraph< int > g(V);
  for(int i = 0; i < E; i++) {
    int x, y, z;
    scanf("%d %d %d", &x, &y, &z);
    g.add_edge(x, y, z);
  }
  auto cost = dijkstra(g, S);
  for(int i = 0; i < V; i++) {
    if(cost[i] == numeric_limits< int >::max()) puts("INF");
    else printf("%d\n", cost[i]);
  }
}


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}
void solve() {
    ll n, x;
    while(cin >> n >> x) {
        if(n == 0 and x == 0)
            return;
        ll ans = 0;
        rep(i, 1, n) {
            rep(j, i + 1, n) {
                int k = x - i - j;
                if(k <= j)
                    break;
                if(k <= n)
                    ans++;
            }
        }
        cout << ans << en;
    }
}

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

    solve();

    /*
    ll t;
    cin >> t;
    REP(i, t) { solve();}
    */

    return 0;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
const int mn=(1e5)+10;
int a[mn],cnt[mn],n,ans;
int main() {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
		cnt[a[i]]++; cnt[a[i]+1]++; cnt[a[i]+2]++;
	}
	for (int i=0;i<mn;i++)
		ans=max(ans,cnt[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int arr[25];
int main(void){
	int n; cin>>n;
	for(int i=1;i<=n;i++) cin>>arr[i];
	int ans=0;
	for(int i=2;i<n;i++){
		if(arr[i]!=min(arr[i-1],min(arr[i],arr[i+1])) && arr[i]!=max(arr[i-1],max(arr[i],arr[i+1]))) ans++;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
    #include<algorithm>
    #include<vector>
    #include<queue>
    #include<stack>
    #include<map>
    #include<string>
    #include<cstring>
    #define ll long long
    #define all(x) (x).begin(),(x).end()
    #define rep(i,n) for(int i = 0;i < (n);++i)
    #define reps(i,n) for(int i = 1;i <= (n);++i)
    using namespace std;
    int main(){
    	cin.tie(0);
    	ios::sync_with_stdio(false);
    	int n;
    	cin >> n;
    	int a;
    	cin >> a;
    	int maxv = a;
    	rep(i,n-1){
    		cin >> a;
    		if(maxv - a >= 2){
    			cout << "No\n";
    			return 0;
    		}
    		maxv = max(a,maxv);
    	}
    	cout << "Yes\n";
    	return 0;
    }

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

#define IOS std::cin.tie(0);std::ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>;

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 55;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    LCIN(N,x);
    vector<ll> a(N);VCIN(a);
    ll ans=0;
    rep(i,N-1){
        if(a[i]+a[i+1]>x){
            ans+=(a[i+1]-(x-a[i]));
            if(x>=a[i])a[i+1]=x-a[i];
            else a[i+1]=0;
        }
    }
    COUT(ans);

    return 0;
}

Measured memory_bytes: 1024
from collections import deque
import copy

digtmp = [[0, 1], [1, 0], [0, -1], [-1, 0]]

def bfs(maze, s):
    que = deque([s])
    maze[s[0]][s[1]] = 0
    ans = 0
    for _ in range(pow(10, 3)):
        fr = que.popleft()
        for d in digtmp:
            to = [fr[0] + d[0], fr[1] + d[1]]
            if maze[to[0]][to[1]] == '.':
                nxt = maze[fr[0]][fr[1]] + 1
                maze[to[0]][to[1]] = nxt
                ans = max(ans, nxt)
                que.append(to)
        if len(que) == 0:
            break
    return ans

def main():
    H, W = map(int, input().split())
    grid = []; road = []
    grid.append(['#']*(W+2))
    for i in range(H):
        tmp = list(input())
        for j in range(W):
            if tmp[j] == '.':
                road.append([i+1, j+1])
        grid.append(['#'] + tmp + ['#'])
    grid.append(['#']*(W+2))
    
    ans = 1
    for r in road:
        maze = copy.deepcopy(grid)
        ans = max(ans, bfs(maze, r))
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define Int int64_t
 
using namespace std;
 
int main() {
	constexpr Int MOD = 1e9 + 7;
	Int N;
	cin >> N;
	vector<Int> C(N);
	for (int i = 0; i < N; ++i) { cin >> C[i]; }

	Int x = 1;
	for (int i = 0; i < 2 * N - 2; ++i) { (x *= 2) %= MOD; }

	sort(C.begin(), C.end());
	Int ans = 0;
	for (int i = 1; i <= N; ++i) {
		(ans += C[i - 1] * x % MOD *  (N - i + 2)) %= MOD;
	}
	cout << ans % MOD << endl;

	return 0;
}


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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> st(H);
    for(auto &s : st) cin >> s;

    for(int i=0; i<H*2; i++){
        cout << st.at(i/2) << endl;
    }
}   

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int n,y;

int main(){
	while (cin >> n&&n){
		int co[10] = {};
		REP(i, n){
			cin >> y;
			if (y >= 70)y = 60 + y % 10;
			co[y / 10]++;
		}
		REP(i, 7){
			cout << co[i] << endl;
		}
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,last,ans=0;
	cin>>n>>last;
	for(int i=2;i<=n;i++)
	{
		int a;
		cin>>a;
		if(a<last)
		{
			ans+=last-a;
			a=last;
		}
		last=a;
	}
	cout<<ans;
	return 0;
 } 

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

int gcd2(int a, int b){
  int a1 = min(a,b);
  int b1 = max(a,b);
  a = a1;
  b = b1;
  while (a > 0){
    b %= a;
    a1 = b;
    b1 = a;
    a = a1;
    b = b1;
  }
  return b;
}

int gcd(int a, int b, int c){
  return gcd2(gcd2(a,b),c);
}

int main() {
  int K;
  cin >> K;
  int ans = 0;
  
  for (int a=1; a<K+1; a++){
    for (int b=1; b<K+1; b++){
      for (int c=1; c<K+1; c++){
        ans += gcd(a,b,c);
      }
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define ll long long
int M=1e9+7;
using namespace std;
int main()
{
	int n;
	cin>>n;
	pair<int,int> p[n];
	for(int i=0;i<n;i++)
	cin>>p[i].first>>p[i].second;
	sort(p,p+n);
	int Min1=INT_MAX,Min2=INT_MAX,Max1=INT_MIN,Max2=INT_MIN;
	for(int i=0;i<n;i++)
	{
		int temp=p[i].first+p[i].second;
		int temp2=p[i].first-p[i].second;
		if(temp>Max1)
		Max1=temp;
		if(temp<Min1)
		Min1=temp;
		if(temp2<Min2)
		Min2=temp2;
		if(temp2>Max2)
		Max2=temp2;
	}
	cout<<max(Max1-Min1,Max2-Min2);
	return 0;
}


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

int main(void){
    vector<int> bell(3);
    cin>>bell[0]>>bell[1]>>bell[2];
    sort(bell.begin(),bell.end());
    cout<<bell[0]+bell[1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int a, b, c, d;
  ci(a, b, c, d);
  if(abs(a - c) <= d){
    co("Yes");
    rt;
  }
  else if(abs(a - b) <= d && abs(b - c) <= d){
    co("Yes");
    rt;
  }
  else{
    co("No");
    rt;
  }
}


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

vector<int> g[101010];

int color[101010]; //must be initialized to -1
int bipartite_graph(int v, int prev, int c) {
        color[v] = c;
        int cnt = c;
        bool ok = true;
        for (auto u : g[v]) if (u != prev) {
                if (color[u] == -1) {
                        int get = bipartite_graph(u, v, 1 - c);
                        if (get == -1) ok = false;
                        cnt += get;
                } else if (color[u] != 1 - c) {
                        ok = false;
                }
        }
        if (!ok) return -1;
        return cnt;
}

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        for (int i = 0; i < m; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                g[a].push_back(b);
                g[b].push_back(a);
        }
        for (int i = 0; i < n; i ++) color[i] = -1;
        int cnt = bipartite_graph(0, -1, 0);
        if (cnt == -1) printf("%lld\n", (long long) n * (n - 1) / 2 - m);
        else printf("%lld\n", (long long) cnt * (n - cnt) - m);
        return 0;
}



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

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  int blue = 0;
  int red = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'B') {
      blue++;
    }
    if (s[i] == 'R') {
      red++;
    }
  }
  if (red > blue) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {

        static void Main(string[] args)
        {
            var K = long.Parse(Console.ReadLine());
            //var NA = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var count = -1;
            //var now = 7;
            //while(now%K != 0)
            //{
            //    now *= 10;
            //    now += 7;
            //    count++;
            //}

            long res = 7;
            long yo = 7;
            
            if(7%K== 0)
            {
                count = 1;
            }
            else
            {
                for (int i = 2; i <= 10000000; i++)
                {
                    res *= 10;
                    res %= K;
                    yo += res;
                    if (yo % K == 0)
                    {
                        count = i;
                        break;
                    }
                    else
                    {
                        yo %= K;
                    }
                }
            }
            


            Console.WriteLine(count);
        }


    }


}


Measured memory_bytes: 27480
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;


int main(){
    while(1){
        int n;
        scanf("%d",&n);
        if(!n)break;

        vector<int> num(10,0);
        for(int i=0;i<n;i++){
            int t;
            scanf("%d",&t);
            num[t]+=1;
        }
        for(int i=0;i<10;i++){
            if(num[i]>0){
                for(int j=0;j<num[i];j++){
                    printf("*");
                }
                printf("\n");
            }else{
                cout << "-" << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

// rep(i, 100) { cout << i << endl; } => 0 1 2 ... 99
#define rep(i, n) for(int i = 0, i##_len = (n); i < (int)n; i++)

// std::sort(all(v));
#define all(x) (x).begin(), (x).end()

// long long int
using ll = long long;

// utility to cast return value of size function to int
#define SZ(x) ((int)(x).size())

// VS defines "_DEBUG" macro when debug configuration.
#if _DEBUG
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define dump(x)
#define debug(x)
#endif

// update max
template<class T>bool chmax(T & prov, const T & cur)
{
	if (cur > prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

// update min
template<class T>bool chmin(T & prov, const T & cur)
{
	if (cur < prov)
	{
		prov = cur;
		return true;
	}
	return false;
}

int main()
{
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> A(Q);
	vector<int> p(N, 0);
	for (auto && a : A)
	{
		cin >> a;
		p[a-1] ++;
	}

	for (auto && n : p)
	{
		if (K - Q + n <= 0)
		{
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 1408
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_orde(ind)
using namespace std;
int main()
{
	sync;
	ll m,n;
	cin>>n>>m;
	ll val[m],arr[n+1]={0},dp[n+1]={0};dp[0]=1;
	input(val,m);
	for(ll i=0;i<m;i++)
	arr[val[i]]=1;
	if(!arr[1])dp[1]=1;
	for(ll i=2;i<=n;i++)
	{
		if(arr[i])continue;
		dp[i]=(dp[i-1]+dp[i-2])%mod;
	//	cout<<i<<" "<<dp[i]<<endl;
	}
	cout<<dp[n];
}

Measured memory_bytes: 2560
N = int(input())
Vs = list(map(int, input().split()))

Vs.sort()

#print(Vs)

initialGousei = (Vs[0] + Vs[1]) / 2

for i in range(2, N):
    initialGousei = (initialGousei + Vs[i]) / 2

print(initialGousei)


Measured memory_bytes: 2940
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
#include <map>
#include <math.h>

using ll = long long;
using namespace std;

int main(){
    int n, a; cin >> n;
    vector<int> count(100100, 0);
    rep(i, n){
        cin >> a;
        count[a+1]++;
    }

    int res=0;
    rep(i, 100100){
        res = max(res, count[i]+count[i+1]+count[i+2]);
    }
    out(res);
}

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

int main(void){
    long long int a,b,tmp;
    while (cin>>a>>b) {
        long long int A=a;
        long long int B=b;
        if (b>a) {
            tmp=b;
            b=a;
            a=tmp;
        }
        while (a%b!=0) {
            tmp=b;
            b=a%b;
            a=tmp;
        }
        cout<<b<<" "<<(A*B/b)<<endl;
    }
}



Measured memory_bytes: 3012
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<map>
using namespace std;

int n;
long long h[111];
long long dp[111][111];
long long MOD=1000000007;

long long hn2h[111];

int hn[111];
map<long long,int>rk;
map<long long,int>::iterator it;
int l;
int m;

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

int main()
{
    int i,j,k;
    int xx;
    long long g,g2;

    scanf("%d",&n);

    for(i=1;i<=n;i++)
    {
        scanf("%lld",&h[i]);

        if(rk.find(h[i])==rk.end())
        {
            rk[h[i]]=1;
        }
    }

    m=0;
    hn2h[0]=0;
    for(it=rk.begin();it!=rk.end();it++)
    {
        m++;
        rk[it->first]=m;

        hn2h[m]=it->first;
    }
    for(i=1;i<=n;i++)
    {
        hn[i]=rk[h[i]];

        //cout<<hn[i]<<' ';
    }
    //cout<<"   hn"<<endl;
    hn[0]=0;


    dp[0][0]=1;
    for(i=0;i<=n-1;i++)
    {
        for(j=0;j<=hn[i];j++)
        {
            int nowh=hn[i];
            int nxth=hn[i+1];
            if(j==0)
            {
                dp[i+1][0]=(dp[i+1][0]+dp[i][j]*2ll)%MOD;
                for(k=nowh+1;k<=nxth;k++)
                {
                    g=hn2h[k]-hn2h[k-1];
                    if(k>1)g++;

                    g2=hn2h[nxth]-hn2h[k];

                    dp[i+1][k]=(dp[i+1][k]+dp[i][j]*(mul(2ll,g)-2ll)%MOD*mul(2ll,g2)%MOD)%MOD;
                }
            }
            else
            {
                if(j>nxth)
                {
                    dp[i+1][0]=(dp[i+1][0]+dp[i][j]*2ll)%MOD;
                }
                else
                {
                    if(nxth<=nowh)
                    {
                        dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
                    }
                    else
                    {
                        g=hn2h[nxth]-hn2h[nowh];
                        dp[i+1][j]=(dp[i+1][j]+dp[i][j]*mul(2ll,g)%MOD)%MOD;
                    }
                }
            }
        }
    }

    long long ans=0;
    for(i=0;i<=m;i++)
    {
        ans=(ans+dp[n][i])%MOD;
    }
    ans=(ans+MOD)%MOD;

    cout<<ans<<endl;

/*
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=hn[i];j++)
        {
            cout<<dp[i][j]<<' ';
        }
        cout<<endl;
    }
*/
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    cin>>n;
    m=6;
    x=6;
    int f=1;
    rep(i,100001){
        strr[i]=0;
    }
    for(i=1;i<=20;i++){
        for(j=i*100;x!=0;x--,j++){
            strr[j]=1;
        }
        m=m+5;
        x=m;
    }

    for(i=2100;i<=100000;i++){
        strr[i]=1;

    }


    if(strr[n]==0) cout<<0<<endl;
    else cout<<1<<endl;
        

    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=200010;
ll h[N];
ll n,ans;
map<ll,ll> m;
int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;++i){
		scanf("%lld",&h[i]);
		++m[i-h[i]];
	}
	ans=0;
	for(ll i=1;i<=n;++i){
		--m[i-h[i]];
		ans+=m[i+h[i]];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 27896
//
//  main.cpp
//  A - Frog 1
//
//  Created by Nishant Dhankhar on 15/01/19.
//  Copyright © 2019 Nishant Dhankhar. All rights reserved.
//
#include <bits/stdc++.h> //REMEMBER TO REMOVE '/'
#include <iostream>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair


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


Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Mmax = 1e5;
int N, M, A[Mmax], B[Mmax];
vector<vector<int>> graph;
vector<bool> visited;

void dfs(int n, vector<int> &path){
	visited[n] = true;
	for(int m: graph[n]){
		if(visited[m]) continue;
		path.push_back(m);
		dfs(m, path);
		break;
	}
}


int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++){
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
	}
	graph = vector<vector<int>>(N);

	for(int i=0; i<M; i++){
		graph[A[i]].push_back(B[i]);
		graph[B[i]].push_back(A[i]);
	}

	visited = vector<bool>(N);
	vector<int> path1, path2;
	path1.push_back(0);
	path2.push_back(0);
	dfs(0, path1);
	dfs(0, path2);


	vector<int> ans;
	for(int i=path1.size()-1; i>=0; i--) ans.push_back(path1[i]);
	for(int i=1; i<path2.size(); i++) ans.push_back(path2[i]);

	cout << ans.size() << endl;
	for(int i=0; i<ans.size(); i++) cout << ans[i]+1 << (i==ans.size()-1?'\n':' ');

	return 0;
}


Measured memory_bytes: 10936
def main():
  ans = 0
  n = int(input())
  a = tuple(map(int, input().split()))
  ov = 10**9+7
  from fractions import gcd
  def lcm(a):
      x = a[0]
      ln = len(a)
      for i in range(1, ln):
          x = (x * a[i]) // gcd(x, a[i])
      return x
  l = lcm(a)
  for i in range(n):
    ans += l//a[i]
  print(ans%ov)
if __name__ == "__main__":
  main()



Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N, M, K;
  cin >> N >> M >> K;
  vector<int64_t> n(N);
  for(int i=0; i<N; i++){
    cin >> n[i];
  }
  vector<int64_t> m(M);
  for(int i=0; i<M; i++){
    cin >> m[i];
  }
  
  vector<int64_t> n_sum(N+1);
  vector<int64_t> m_sum(M+1);
  for(int i=0; i<N; i++){
    n_sum[i+1] = n_sum[i] + n[i];
  }
  for(int i=0; i<M; i++){
    m_sum[i+1] = m_sum[i] + m[i];
  }
  
  vector<int64_t>::iterator pos;
  int64_t idx;
  
  int64_t ans = 0;
  
  for(int64_t i=0; i<=N; i++){
    if(K - n_sum[i] < 0){
      break;
    }
    pos = upper_bound(m_sum.begin(),m_sum.end(), K - n_sum[i]);
    idx = distance(m_sum.begin(),pos);
    ans = max(ans, i+idx-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 9524
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,p[100005];
	cin >>n ;
	for(int i=0;i<n;i++)
		cin >> p[i] ;
	sort(p,p+n);
//	if(p[n/2]!=p[n/2-1]) {
//		if(p[n/2]-)
//	}
	cout <<p[n/2]-p[n/2-1];
	
}

Measured memory_bytes: 640
// --------------
// Tejas Pandey  |
// 01 - 12 - 19  |
// SUMOMITO PC'19|
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{"\n";
		//cout << "Case #" << c-t << ": ";
		int a;
		cin >> a;
		int b = a;
		a *= 100;
		a = ceil(a/108.0);
		if((floor)(a * 1.08) == b)
			cout << a;
		else
			cout << ":(";
	}
	return 0;
}

Measured memory_bytes: 256
import bisect

a,b,q = map(int,input().split())
s = [-10**11] + [int(input()) for i in range(a)] + [10**11]
t = [-10**11] + [int(input()) for i in range(b)] + [10**11]



for i in range(q):
    x = int(input())
    xs = bisect.bisect_right(s,x)
    xt = bisect.bisect_right(t,x)
    ss = [x-s[xs-1],s[xs]-x]
    tt = [x-t[xt-1],t[xt]-x]
    print(min(max(ss[0],tt[0]), max(ss[1],tt[1]), ss[0]*2+tt[1], ss[1]*2+tt[0], tt[0]*2+ss[1], tt[1]*2+ss[0]))


Measured memory_bytes: 14608
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define P pair<int, int>
#define P2 pair<int, P>
#define P3 pair<int, P2>
#define fr(i, a, b) for (int i = a; i < b; i++)    //[a, b)
#define frr(i, a, b) for (int i = b; i >= a; i--)  //[a, b]
#define rp(i, b) for (int i = 0; i < b; i++)       //[0, b)
#define rrp(i, b) for (int i = b; i >= 0; i--)     //[0, b]
#define cbuf(buf, init) memset(buf, init, sizeof(buf))

int N;

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

    int p = N % 10;
    N /= 10;
    if (p == N % 10) {
        N /= 10;
        if (p == N % 10) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else {
        p = N % 10;
        N /= 10;
        if (p == N % 10) {
            N /= 10;
            if (p == N % 10) {
                cout << "Yes" << endl;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
}


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

struct Katana {
    int a, b;
};

int main() {
    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    vector<Katana> k(N);
    for (int i = 0; i < N; i++) {
        cin >> k[i].a >> k[i].b;
    }

    sort(k.begin(), k.end(), [&](const Katana& lhs, const Katana& rhs) {
        return (lhs.b == rhs.b ? lhs.a > rhs.a : lhs.b > rhs.b);
    });

    int max_a_index = -1, max_a = INT_MIN;
    for (int i = 0; i < N; i++) {
         if (max_a <= k[i].a) {
            max_a_index = i;
            max_a = k[i].a;
        }
    }

    int ans = 0;
    for (int i = 0; i < N && k[i].b >= max_a; i++) {
        if (i == max_a_index) {
            continue;
        }
        ans++;
        H -= k[i].b;
        if (H <= 0) {
            cout << ans << endl;
            return 0;
        }
    }

    if (k[max_a_index].a < k[max_a_index].b) {
        if (H <= k[max_a_index].b) {
            //投げて終わり
            ans++;
        } else if ((H - k[max_a_index].b) % k[max_a_index].a == 0) {
            ans += (H - k[max_a_index].b) / k[max_a_index].a + 1;
        } else {
            ans += (H - k[max_a_index].b) / k[max_a_index].a + 2;
        }
    } else {
        if (H % k[max_a_index].a == 0) {
            ans += H / k[max_a_index].a;
        } else {
            ans += H / k[max_a_index].a + 1;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N,A,B;
    cin >> N >> A >> B;
    cout << min(A,B) << " " << max(0,(A + B) - N) << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	std::string  w[100];
	std::map<string, ll> mp;
	rep (i,n){
		cin >> w[i];
		if (i != 0 && (w[i - 1].back() != w[i].front() || mp[w[i]]>0)) {
			std::cout << "No" << endl;
			return 0;
		}
		mp[w[i]]++;
	}
	std::cout << "Yes" << endl;
	return 0;
}

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

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

    vector<long> city(n, 0);

    long tmp = 0;
    long once;
    long l;

    for (long i = 1; i <= k; i++)
    {
        tmp = a[tmp];

        if (city[tmp] == 0)
            city[tmp] = i;
        else
        {
            once = city[tmp];
            l = i - once;
            break;
        }
    }
    if (l != 0)
    {

        long des = (k - once) % l;

        for (long i = 1; i <= des; i++)
        {
            tmp = a[tmp];
        }

    }
    
    cout << tmp + 1 << endl;
    
}

Measured memory_bytes: 6436
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
vector<ll> C(26);
vector<vector<ll>> S;

ll change_evaluation(vector<ll>& T,ll day) {
  day -= 1;
  vector<ll> last(26, -1);
  vector<ll> next(26, T.size());
  ll old = T.at(day) - 1;
  for (ll i = 0; i < day; ++i) {
    last.at(T.at(i) - 1) = i;
  }
  for (ll i = T.size() - 1; i > day; --i) {
    next.at(T.at(i) - 1) =  i;
  }
  ll max_t = 0, max_score = -INF;
  for (ll t = 0; t < 26; ++t) {
    ll score = S.at(day).at(t) - S.at(day).at(old);
    score += (next.at(t) - day) * (day - last.at(t)) * C.at(t);
    score -= (next.at(old) - day) * (day - last.at(old)) * C.at(old);
    if (score > max_score) {
      max_score = score;
      max_t = t;
    }
  }
  return max_t;
}

ll evaluation(ll t, ll day, vector<ll>& last) {
  ll score = 0;
  score += S.at(day).at(t);
  for (ll j = 0; j < 26; ++j) {
    if (j == t) {
      continue;
    }
    score -= (day + 1 - last.at(j)) * C.at(j);
  }
  return score;
}

ll whole_evaluation(vector<ll>& T) {
  ll D = T.size();
  vector<ll> last(26, 0);
  ll score = 0;
  for (ll i = 0; i < D; ++i) {
    ll contest = T.at(i) - 1;
    last.at(contest) = i + 1;
    score += S.at(i).at(contest);
    for (ll j = 0; j < 26; ++j) {
      score -= (i + 1 - last.at(j)) * C.at(j);
    }
  }
  return score;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  //-----------input-------------
  ll D;
  cin >> D;
  vector<ll> T(D);
  S = vector<vector<ll>>(D, vector<ll>(26));
  for (ll i = 0; i < 26; ++i) {
    cin >> C.at(i);
  }
  for (ll i = 0; i < D; ++i) {
    for (ll j = 0; j < 26; ++j) {
      cin >> S.at(i).at(j);
    }
  }
  //--------------------------------------
  vector<ll> last(26, 0);
  for (ll day = 0; day < D; ++day) {
    ll max_contest = 0;
    ll max_score = -INF;
    for (ll contest = 0; contest < 26; ++contest) {
      ll temp_score = evaluation(contest, day, last);
      if (temp_score > max_score) {
        max_score = temp_score;
        max_contest = contest + 1;
      }
    }
    last.at(max_contest - 1) = day;
    T.at(day) = max_contest;
  }

  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand(1, T.size());
  for (ll i = 0; i < 1000; ++i) {
    ll random = rand(mt);
    ll max_t = change_evaluation(T, random);
    // cout << max_t << " rand" << "\n";
    T.at(random - 1) = max_t + 1;
  }

  // ll score = whole_evaluation(T);
  // cout << score << "\n";

  for (ll i = 0; i < D; ++i) {
    cout << T.at(i) << "\n";
  }

  // vector<ll> ans = evaluation(C, S, T);
  // for (ll i = 0; i < ans.size(); ++i) {
  //   cout << ans.at(i) << "\n";
  // }
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


signed main(){
  int n,m;cin>>n>>m;
  int a[110];rep(i,n)cin>>a[i];
  int s = 0;
  rep(i,n)s += a[i];
  sort(a, a+n,greater<int>());
  if(a[m-1]*4*m >= s){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
n=int(input())
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
print("Yes" if n%digitSum(n)==0 else "No")

Measured memory_bytes: 9112
i = 1
a = []
b = []

while True :
    x, y = map(int, input().split())
    if x == 0 and y == 0 :
        break
    a.append(x)
    b.append(y)
    i += 1
    
for j in range(1, i) :
    if a[j - 1] < b[j - 1] :
        print(a[j - 1], b[j - 1])
    else :
        print(b[j - 1], a[j - 1])


Measured memory_bytes: 6124
from fractions import gcd

class SegTree:
    def __init__(self, N, A, f, e):
        """
        N: A の要素数
        A: セグ木に乗せたい配列
        f: 二項演算 (モノイドじゃなきゃだめ)
        e: f の単位元
        """
        n = 2**(N-1).bit_length() # セグ木の葉の数（N 以上の最小の2べき）
        c = [e] * (2*n)

        for i in range(N):
            c[i+n] = A[i] # 葉をA[i]の値にする
        
        for i in range(n-1, 0, -1):
            c[i] = f(c[i<<1|0], c[i<<1|1]) # 子を使ってボトムアップに値を更新していく
        
        self.n = n # セグ木の葉の数（N 以上の最小の2べき）
        self.c = c # セグ木の配列
        self.e = e
        self.f = f
    
    def update(self, k, x):
        k += self.n
        self.c[k] = x # 対応する葉に移動

        # 祖先をたどって更新していく
        while k > 1:
            k >>= 1
            self.c[k] = self.f(self.c[k<<1|0], self.c[k<<1|1])

    def query(self, l, r):
        res = self.e
        l += self.n; r += self.n # 対応する葉に移動

        while l < r: # 範囲がかぶらない間
            if l & 1: # 左端が右側にいるなら
                res = self.f(res, self.c[l]) # その値と res の積をとって
                l += 1 # 右に 1 動く

            if r & 1: # 右端が左側にいるなら
                r -= 1 # 左に 1 動いて (右端は閉なので)
                res = self.f(res, self.c[r]) # その値と res の積をとる

            l >>= 1; r >>= 1 # 親に移動
        
        return res

N = int(input())
A = [int(i) for i in input().split()]

seg = SegTree(N, A, gcd, 0)

res = 0
for i in range(N):
    res = max(res, gcd(seg.query(0, i), seg.query(i+1, N)))

print(res)

Measured memory_bytes: 16152