akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n, k;
    cin >> n >> k;
    ll ans = 0;
    for(int b = k + 1; b <= n; ++b){
        ans += n / b * (b - k) + max(0, n % b - k + 1);
    }
    if(k == 0)  ans -= n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  
  if(((a == b) && (a != c)) || ((b == c) && (a != b)) || ((a == c) && (a != b)))printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	char s[200], p[100],w[100];

	cin >> s >> p;

	strcpy(w, s);
	strcat(s, w);

	if (strstr(s, p) == NULL) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
    return 0;
}




Measured memory_bytes: 3104
n,c = map(int,input().split())
d = [list(map(int,input().split())) for j in range(c)]
cl = [list(map(int,input().split())) for j in range(n)]
check = 1;checkls = [[0 for i in range(c)] for j in range(3)]
for i in range(n):
    for j in range(n):
        check = ((i+1)+(j+1))%3
        checkls[check][cl[i][j]-1] += 1
ans = 1000000000000000000000000000000000000000000000000000000000000
for i in range(c):
        for j in range(c):
                if i == j:continue
                for k in range(c):
                        if i == k or j == k:continue
                        add = 0;ls = [i,j,k]
                        for l in range(3):
                                for m in range(c):
                                        num = checkls[l][m]
                                        add += d[m][ls[l]] * num
                        ans = min(ans,add)
print(ans)

Measured memory_bytes: 5620
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;


public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		List<Integer[]> needs = new LinkedList<>();
		for(int i=0; i<M; i++){
			int a = Integer.parseInt(sc.next());
			int b = Integer.parseInt(sc.next());
			Integer[] need = {a,b};
			needs.add(need);
		}
		
		needs.sort((a,b) -> Integer.compare(a[1], b[1]));
		
		int ans = 0; 
		int pos;
		while(needs.size()>0){
			pos = needs.get(0)[1];
			ans++;
			Iterator<Integer[]> iterator = needs.iterator();
			while(iterator.hasNext()){
				Integer[] need = iterator.next();
				if(need[0] < pos && need[1] >= pos)
					iterator.remove();
			}
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 68480
import sys
H,W = input().split()
H = int(H)
W = int(W)
s = []

s.append("."*(W+2))
for i in range(H):
    s.append("."+input()+".")

s.append("."*(W+2))


for i in range(1,1+H):
    for j in range(1,1+W):
#        print(j,i)
        if s[i][j] == "#":
            if s[i][j-1] != "#" and s[i][j+1] != "#" and s[i-1][j] != "#" and s[i+1][j] != "#":
                print("No")

                sys.exit()

print("Yes")


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int AtoC;
    int AtoB;
    int BtoC;
    if (a < c)
        AtoC = c-a;
    else
        AtoC = a-c;

    if (a < b)
        AtoB = b-a;
    else
        AtoB = a-b;

    if (b < c)
        BtoC = c-b;
    else
        BtoC = b-c;

    if (AtoC <= d)
        cout << "Yes";
    else
        if ( AtoB <= d && BtoC <= d)
            cout << "Yes";
        else
            cout << "No";
    return 0;
}

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

int main()
{
  string n;
  string data[8]={
    "*****     ",
    "     *****",
    "==========",
    " **** ****",
    "* **** ***",
    "** **** **",
    "*** **** *",
    "**** **** "
  };
  bool flag =false;
  for(;cin>>n;)
    {
      if(flag)
	cout<<endl;
      flag=true;
      while(n.size()<5)
	n="0"+n;
      char ans[8][5];
      for(int i=0;i<5;i++)
	{
	  int x=n[i]-'0';
	  for(int j=0;j<8;j++)
	    {
	      //	      cout<<"j,x="<<j<<","<<x;
	      //	      cout<<"  "<<data[j][x]<<endl;
	    ans[j][i]=data[j][x];
	    }
	}

      for(int i=0;i<8;i++,cout<<endl)
	for(int j=0;j<5;j++)
	  cout<<ans[i][j];
      
    }

}

Measured memory_bytes: 1188
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
const int INF = 1000000007;
ll A, B;

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1ll) ret[n] = 1ll;
  return ret;
}

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

  cin >> A >> B;
  ll g = gcd(A, B);
  map<ll, ll> M = prime_factor(g);
  cout << M.size()+1 << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

#define MAX 100000

vector<int> G[MAX];

int rec(int cur) {
    if (G[cur].empty()) {
        return 0;
    }
    vector<int> v;
    for (int to : G[cur]) {
        v.emplace_back(rec(to));
    }
    sort(ALL(v));
    reverse(ALL(v));
    int res = v.size();
    for (int i = 0; i < (int)v.size(); i++) {
        res = max(res, v[i] + i);
    }
    res++;
    return res;
}

signed main() {
    int n;
    cin >> n;
    int a;
    for (int i = 1; i < n; i++) {
        cin >> a;
        a--;
        G[a].emplace_back(i);
    }
    cout << rec(0) - 1 << endl;
    return 0;
}

Measured memory_bytes: 18444
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    map<char, char> rel;
    rel['A'] = 'T';
    rel['T'] = 'A';
    rel['C'] = 'G';
    rel['G'] = 'C';
    char b;
    cin >> b;
    cout << rel[b] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int N, a;
    fscanf(stdin, "%d", &N);
    int m[100001];
    for (int i = 0; i < N; i++) {
        m[i] = 0;
    }
    for (int i = 0; i < N; i++) {
        fscanf(stdin, "%d", &a);
        m[a]++;
        if (a >= 1) {
            m[a - 1]++;
        }
        if (a <= 99999) {
            m[a + 1]++;
        }
    }
    int max = 1;
    for (int i = 0; i < N; i++) {
        if (m[i] > max) {
            max = m[i];
        }
    }
    cout << max;
}


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

primenum = [0]*101

def make_divisor(n):
    res = []
    for i in range(1,int(n**0.5+1)):
        if i*i == n:
            res.append(i)
        else:
            res.append(i)
            res.append(n//i)
    return res

def fact(n):
    if n==1:
        return 
    else:
        divs = make_divisor(n)
        divs.sort()
        tmp = n
        idx = 1
        while(tmp>1):
            while (tmp%divs[idx]==0):
                primenum[divs[idx]] += 1
                tmp //= divs[idx]
            idx += 1
        fact(n-1)
        return 


fact(N)

ans = 0
primenum.sort(reverse = True)
idx = 0
while primenum[idx]>=74: idx += 1
ans += idx

idx2 = 0
while primenum[idx]>=24: idx += 1
while primenum[idx+idx2]>=2:idx2 += 1
ans += idx*(idx-1+idx2)

idx = 0
idx2 = 0
while primenum[idx]>=14: idx += 1
while primenum[idx+idx2]>=4:idx2 += 1
ans += idx*(idx-1+idx2)

idx = idx+idx2
idx2 = 0
while primenum[idx+idx2]>=2: idx2 += 1
ans += idx*(idx-1)//2*(idx-2+idx2)
print(ans)

Measured memory_bytes: 3064
#ABC177 C
N = int(input())
A = list(map(int,input().split()))
max = A[0]
F = [0]

for i in range(1,N):
  if max > A[i]:
    F.append(max - A[i])
  else:
    max = A[i]
    F.append(0)

print(sum(F))


Measured memory_bytes: 32244
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl
using namespace std;
int max_int = 2147483647;
int prime = 10e9+7;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;




signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vec(a,n);
    REP(i,n){
        cin >> a[i];
        a[i]--;
    }
    vec(b,n);
    int itr = 0;
    int cnt = 0;
    int loop;
    while(true){
        itr = a[itr];
        cnt++;
        if(b[itr] != 0){
            loop = cnt - b[itr];
            break;
        }
        b[itr] = cnt;
    }
    int ans;
    if(b[itr] > k){
        ans = k;
    }
    else{
        k -= b[itr];
        ans = b[itr] + (k%loop);
    }
    REP(i,n){
        if(b[i] == ans){
            print(i+1);
            return 0;
        }
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

//key以上の初めてのitr
int nibul(auto a,auto b){return lower_bound(All(a),b) - a.begin();}
//key以下の最後のitr
int nibuu(auto a,auto b){return upper_bound(All(a),b) - a.begin()-1;}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 6368
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

#define MOD 1000000007

const int N = 1<<18;
int a[N][2];

int main() {
	int n;
	cin >> n;
	REP(i, 1 << n)scanf("%d", &a[i][0]);
	REP(i, n) {
		REP(j, 1 << n) {
			if ((j & (1 << i))) {
				auto x = j ^ (1 << i);
				REP(k, 2) {
					if (a[j][0] < a[x][k]) {
						a[j][1] = a[j][0];
						a[j][0] = a[x][k];
					}
					else if (a[j][1] < a[x][k]) {
						a[j][1] = a[x][k];
					}
				}
			}
		}
	}
	int ret = -1;
	FOR(i, 1, 1 << n) {
		ret = max(ret, a[i][0] + a[i][1]);
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ob pop_back
#define xx first
#define yy second
#define dob double
#define rin(i,n,k) for(int i=0;i<n;i+=k)
#define int long long int
#define ss size()
using namespace std;
const int M=1e9+7,maxn=100010;
std::vector<int> adj[maxn];
std::vector<int> v1;
int ans,n,k,m,x,y,q,par[maxn],h[maxn],mach[maxn],sk[maxn],dp[maxn];
bool mark[maxn],bpart[maxn];
string s,s1,s2;
map <string ,int> mp;
bool markchaild[maxn];
bool dfsmach(int v){
    if(v==-1) return true;
    if(mark[v]==1) return false;
    mark[v]=1;
    for(int i=0;i<adj[v].ss;i++){
        int u=adj[v][i];
        if(dfsmach(mach[u])){
            bpart[u]=((bpart[v]+1)%2);
            mach[u]=v;
            mach[v]=u;
            return true;
        }
    }
    return false;
}


int32_t main() {
    cin>>n>>m>>k;
    if(n<=k&&m>=k)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 2688
N, A, B = map(int, input().split())

# まずN <= 10**4だからO(N)で間に合う
ans = 0
for i in range(1, N+1):
    ii = i
    num = 0
    while ii != 0:
        num += ii % 10  # iiの1の位を加算 (ex. ii = 234 -> num = 4)
        ii = ii // 10  # 一桁右にずらす (ex. 234 -> 23)

    if A <= num and num <= B:
        ans += i
print(ans)



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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill((T*)array, (T*)(array+N), val);
}
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class DWidespread {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        ll a, b;
        in >> n >> a >> b;
        vector<ll> h(n, 0);
        rep(i, n){
            in >> h[i];
        }

        sort(all(h), greater<ll>());

        ll diff = a - b;
        function<bool(ll)> f = [&](ll mid) {
            ll cnt = 0;
            rep(i, n){
                if(h[i] > b*mid){
                    ll h_buf = h[i] - b*mid;
                    cnt += ceill(h_buf, diff);
                }else break;
            }
            return cnt <= mid;
        };

        ll left = 0;
        ll right = 1e9;
        ll mid;
        while(left+1 < right){
            mid = (left + right) / 2;
            if(!f(mid)){
                left = mid;
            }else{
                right = mid;
            }
        }

        out << right << endl;
	}
};


int main() {
	DWidespread solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
import numpy as np
R, G, B, N = map(int, input().split())
r = np.arange(0, int(N/R)+1)
g = np.arange(0, int(N/G)+1)
rg = r[:, np.newaxis]*R+g[np.newaxis, :]*G
mask = (rg<=N) & ((N-rg)%B==0)
print(np.sum(mask))


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

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;

  int ans = X / (Y + Z);
  if(X % (Y + Z) < Z) {
    cout << X / (Y + Z) - 1;
  } else {
    cout << X / (Y + Z);
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using i128 = boost::multiprecision::int128_t;
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


VV G;

void ok() {
  cout << "First\n";
  exit(0);
}

int dfs(int u, int p=-1) {
  int cnt = 0;
  for (int v : G[u]) if (v != p) {
    if (dfs(v, u)) ++cnt;
  }
  if (cnt > 1) ok();
  return cnt^1;
}


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

  G.assign(n, V());
  rep(i, n-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  if (dfs(0)) ok();
  cout << "Second\n";
  return 0;
}


Measured memory_bytes: 8696
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000001145
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
//typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};

int ans=-INF;
int n,m;
int f[111][6][2];
int p[111][11];
signed main(){
	cin>>n;
	rep(i,n){
		rep(j,5){
			rep(k,2){
				cin>>f[i][j][k];
			}
		}
	}
	rep(i,n){
		rep(j,11){
			cin>>p[i][j];
		}
	}
	rep(i,1<<10){
		if(i==0)continue;
		int smallans=0;
		rep(j,n){
			int cnt=0;//店jとかぶっている時間帯の数
			rep(k,10){
				if(((1<<k)&i)&&f[j][k/2][k%2])cnt++;
			}
			smallans+=p[j][cnt];
		}
		ans=max(ans,smallans);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
// Problem : 
// 			D - Handstand 2
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int n; cin>>n;
	int dp[10][10] = {0};
	rep(i,1,n+1){
		int a = i,b = i%10;
		while(a>=10) a /= 10;
		dp[a][b]++;
	}
	int ans = 0;
	fo(i,10){
		fo(j,10){
			ans += dp[i][j]*dp[j][i];
		}
	}
	cout<<ans;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

#define NIL -1
#define MAX 250

// 1 originとして使う
int heap[MAX+1];

int parent(int i) { return i/2;}
int left(int i) {return 2*i;}
int right(int i){return 2*i + 1;}

int main(){

  int H;
  scanf("%d", &H);

  for(int i=1; i<=H; i++){
    scanf("%d", &heap[i]);
  }

  for(int i=1; i<=H; i++){
    printf("node %d: ", i);
    printf("key = %d, ", heap[i]);

    if(parent(i) > 0){
      printf("parent key = %d, ", heap[parent(i)]);
    }

    if(left(i) <= H) printf("left key = %d, ", heap[left(i)]);
    if(right(i) <= H) printf("right key = %d, " , heap[right(i)]);
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using ld = long double;
const ll ATCODER_AMARI = 1000000007; //10^9 + 7
const ll INF = 10000000000000;

//階乗関数　ATCODER_AMARIに注意
ll factorial(ll k){
  ll sum = 1;
  for(int i = 1 ; i < k + 1; i++) {
    sum *= i;
    //sum = sum % ATCODER_AMARI;
  }
  return sum;
}

int main() {
  int h,w;
  cin >> h >> w;

  vector<vector<char>> s(h,vector<char>(w));
  
  rep(i,h) {
    rep(j,w) {
      cin >> s.at(i).at(j);
    }
  }

  bool flag = true;

  rep(i,h) {
    rep(j,w) {

      char tmp = s.at(i).at(j);

      if(tmp == '#') {
        if(i != 0) {
          if(s.at(i - 1).at(j) == '#') continue;
        }
        if(i != h - 1) {
          if(s.at(i + 1).at(j) == '#') continue;
        }
        if(j != 0) {
          if(s.at(i).at(j - 1) == '#') continue;
        }
        if(j != w - 1) {
          if(s.at(i).at(j + 1) == '#') continue;
        }

        flag = false;
        
      }
      
    }
  }


  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <iostream>

int main() {
    int A, B, K;
    std::cin >> A >> B >> K;
    int cnt = 0;
    int test = std::max(A, B);
    while (cnt < K) {
        if (A % test == 0 && B % test == 0) ++cnt;
        --test;
    }
    std::cout << test + 1 << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>


using namespace std;

typedef long long ll;

int main() {
	int N, num = 0;
	ll D;
	cin>>N>>D;
	for(int i=0 ; i<N ; i++) {
		ll x, y;
		cin>>x>>y;
		if(x*x+y*y <= D*D) num++;
	}
	cout<<num<<endl;
	return 0;
}

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

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

    int toright = 0;
    for(int i = x; i <= n; i++) toright += a[i];
    int toleft = 0;
    for(int i = x; i >= 0; i--) toleft += a[i];

    if(toright < toleft) cout << toright << endl;
    else cout << toleft << endl;
    return 0;
}

Measured memory_bytes: 3624
S=input()
sum_a = 0
index = []
area = []
pos = []
for i,s in enumerate(S):
    if(s=="\\"):
        index.append(i)
    if(s=="/" and index):
        tmp = i - index[-1]
        sum_a += tmp
        pop = index.pop()
        while pos and pop < pos[-1]:
            tmp += area.pop()
            pos.pop()
        pos += [pop]
        area += [tmp]
        
print(sum_a)
print(len(area),*(area))

Measured memory_bytes: 8052
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
     ll n;
     cin>>n;
     ll d1[n],d2[n];
     for(int i=0;i<n;i++)
        cin>>d1[i]>>d2[i];
        ll c=0;
        bool f=0;
     for(int i=0;i<n;i++)
     {
         if(d1[i]==d2[i])
         {
             c=1;
             for(int j=i+1;j<=n;j++)
             {
                 if(d1[j]==d2[j])
                    c++;
                 else
                    break;
             }
             if(c>=3)
             {
                 f=1;break;
             }
         }
     }
     if(f==0)cout<<"No"<<endl;
     else
        cout<<"Yes"<<endl;
}



Measured memory_bytes: 3632
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
#include<set>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;


int main(){
      int n,m;
      cin>>n>>m;
      priority_queue<double> q;
      rep0(i,n){
            double a;
            cin>>a;
            q.push(a);
      }
      rep0(j,m){
            double pos=q.top();
            q.pop();
            pos/=2;
            q.push(pos);
      }
      ll ans=0;
      rep0(i,n){
            int pos=q.top();
            q.pop();
            ans+=pos;
      }
      cout<<ans<<endl;
      return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n;
  cin >> n;
  map<string,int> m;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    if(m.count(s))
    m[s]++;
    else
    m[s]=1;
  }
  int max=0;
  for (auto p : m) {
    auto v = p.second;
    if(max<v)
    max=v;
  }
  for (auto p : m) {
    auto k = p.first;
    auto v = p.second;
    if(v==max)
    cout << k << endl;
  }
}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll ret = 0;
string s;
ll w[101];
ll v[ARRAY];
ll dp[101][ARRAY];

ll knapsack(ll i, ll j) {
  if (i < 0) return 0;
  if (dp[i][j] != -1) return dp[i][j];
  ll ans;
  if (j >= w[i]) {
    ans = max(knapsack(i-1, j), v[i] + knapsack(i-1, j-w[i])); 
  } else {
    ans = knapsack(i-1, j);
  }
  dp[i][j] = ans;
  return ans;
}

int main(void){
  ll N, W;
  IN(N);
  IN(W);
  REP(i, N) {
    IN(w[i]);
    IN(v[i]);
  }

  FOR(i, 0, 101) {
    FOR(j, 0, ARRAY) {
      dp[i][j] = -1;
    }
  }

  ret = knapsack(N-1, W);
  PRINT(ret);

}


Measured memory_bytes: 79104
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int mincost = 2147483647;
  for (int cq = 0; cq <= 100000; cq++) {
    int aq = max(x - cq, 0);
    int bq = max(y - cq, 0);
    int cost = aq * a + bq * b + c * cq * 2;
    if (mincost > cost) mincost = cost;
  }
  cout << mincost << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    int ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << ab * bc / 2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define pb push_back
#define fs first
#define sc second
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

const double EPS = 1e-9;

vvi E;
bool vis[100'050];

void dfs(int at) {
    if(vis[at]) return;
    vis[at] = true;
    for(auto  a : E[at]) dfs(a);
}

int main() {
    cin.sync_with_stdio(false);
    memset(vis,0,sizeof(vis));
    int n,m;
    cin >> n >> m;
    E = vvi(n,vi());
    rep(i,0,m) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        E[a].pb(b);
        E[b].pb(a);
    }
    int tots = 0;
    rep(i,0,n) {
        if(!vis[i]) {
            tots++;
            dfs(i);
        }
    }
    cout << tots-1 << endl;
}



Measured memory_bytes: 9304
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
int main() {
	ll N;
	cin >> N;
	vector<ll>a(N);
	rep(i, N)cin >> a[i];
	rep(i, N) {
		if (a[i] % 2 == 0) {

			if (a[i] % 3 == 0 || a[i] % 5 == 0) {

				
			}
			else {
				cout << "DENIED";
				return 0;
			}

		}
	}
				cout << "APPROVED";


}


Measured memory_bytes: 256
N,W=map(int,input().split())


#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合S

weight=[0]*110
value=[0]*110

S = [[0 for j in range(3)] for i in range(100010)]
DP= [[0 for j in range(100100)] for i in range(110)]

for i in range(N):
    A,B=map(int,input().split())
    weight[i]=A
    value[i]=B
    
for i in range(N):
    for w in range(W+1):
        if w>=weight[i]:
            DP[i+1][w]=max(DP[i][w-weight[i]]+value[i],DP[i][w])
        else:
            DP[i+1][w]=DP[i][w]

print(DP[N][W])

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

int n;
vector< int > a, b, c;

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

  cin >> n;
  a.resize(n);
  b.resize(n);
  c.resize(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = 0; i < n; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }

  vector< pair< int, int > > all;
  for(int i = 0; i < n; i++){
    all.push_back(pair< int, int >(a[i], 2));
    all.push_back(pair< int, int >(b[i], 1));
    all.push_back(pair< int, int >(c[i], 0));
  }
  sort(all.begin(), all.end());

  long da[3 * n + 1];
  long db[3 * n + 1];
  long dc[3 * n + 1];
  da[0] = 0;
  for(int i = 1; i <= 3 * n; i++){
    if(all[i - 1].second == 2){
      da[i] = da[i - 1] + 1;
    }
    else{
      da[i] = da[i - 1];
    }
  }
  db[0] = 0;
  for(int i = 1; i <= 3 * n; i++){
    if(all[i - 1].second == 1){
      db[i] = db[i - 1] + da[i];
    }
    else{
      db[i] = db[i - 1];
    }
  }
  dc[0] = 0;
  for(int i = 1; i <= 3 * n; i++){
    if(all[i - 1].second == 0){
      dc[i] = dc[i - 1] + db[i];
    }
    else{
      dc[i] = dc[i - 1];
    }
  }

  cout << dc[3 * n] << endl;

  return 0;
}

Measured memory_bytes: 12652
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	} 
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := scanInts(n)

	ma := 0
	for i := 1; i < n; i++ {
		done := make([]bool, n)
		sum := 0
		for k := 0;; k++ {
			if n-1-k*i < 0 || (k+1)*(n-1-k*i)-(n-1) < 0{
				break
			}

			if done[k*i] || done[n-1-k*i] || k*i == n-1-k*i {
				break
			}
			done[k*i],done[n-1-k*i] = true, true
			sum += s[k*i]+s[n-1-k*i]
			ma = max(ma, sum)
			// debug(i,k,sum)
		}
	}

	fmt.Fprintln(wr, ma)
}


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

typedef signed long long ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()

#define DEBUG

int main()
{
	int w, h;
	cin >> h >> w;
	for(int i = 0; w != 0 && h != 0; i++)
	{
		rep(j, h)
		{
			rep(k, w)
			{
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  ll n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];

  sort(all(a));

  ll cnt=0;
  ll tmp=a[0];
  ll cnts=1;
  Rep(i,1,n){
    if(a[i]!=a[i-1]){if(cnts%2==1)cnt++;tmp=a[i];cnts=1;}
    else{cnts++;}
  }
  if(cnts%2==1)cnt++;
  cout<<cnt<<endl;
    
    
  return 0;
}


Measured memory_bytes: 3972
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    usize n;
    std::cin >> n;
    vec<usize> a(n);
    for (usize& x: a) std::cin >> x;
    a.push_back(0);
    n++;

    usize ans = 0;
    for (usize i=0, sum = 0; i<n; i++) {
        if (a.at(i)==0) {
            ans += sum / 2;
            sum = 0;
        } else {
            sum += a.at(i);
        }
    }

    std::cout << ans << '\n';
}


Measured memory_bytes: 1792
fn main(){
    proconio::input!{
        k: u64,
        mut a: u64,
        b: u64
    }
    let mut flg = false;
    while a <= b{
        if a % k == 0{
            flg = true;
        } 
        a += 1;
    }
    if flg{
        println!("OK");
    }else{
        println!("NG");
    }
}

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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(5e3) + 17;

ll N;

bool read() {
    if (!(cin >> N))
        return false;

    return true;
}

void solve() {
    ll n = 1;
    for (; n * (n + 1) / 2 < N; ++n) { }
    cout << n << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



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

int main(){
  int i,j = 0,n,m,*A,*B,count = 0;
  
  scanf("%d",&n);
  A = (int *)malloc(n * sizeof(int));
  for(i = 0;i < n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&m);
  B = (int *)malloc(m * sizeof(int));
  for(i = 0;i < m;i++){
    scanf("%d",&B[i]);
  }
  
  for(j = 0;j < m;j++){
    for(i = 0;i < n;i++){
      if(A[i] == B[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);
  

  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll h,a;
    cin>>h>>a;
    cout<<(h+a-1)/a<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,num,ta,tb,cnt=0;
  vector<int> gr[51];
  bool changed=true,all_empty=false;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    cin >> ta>>tb;
    gr[ta-1].push_back(tb-1);
    gr[tb-1].push_back(ta-1);
  }
  while(changed==true){
    changed=false;
    all_empty=true;
    for(int i=0;i<n;i++){
      if(gr[i].size()>=1) all_empty=false;
      if(gr[i].size()==1){
        num = gr[i][0];
        for(auto j=gr[num].begin();j!=gr[num].end();j++){
          if(i==*(j)){
            gr[num].erase(j);
            break;
          }
        }
        gr[i].clear();
        cnt++;
        changed=true;
      }
    }
    if(all_empty) break;
  }
  cout << cnt << endl;
}



Measured memory_bytes: 256
def myAnswer(N:int,s:str,t:str) -> int:
   if(s == t): return N
   if(N == 1): return 2
   total = N * 2
   for i in range(N):
      counter = 0
      n = i
      for j in range(N-i):
         # print(s[n],t[j])
         if(s[n] == t[j]):
            n += 1
            counter += 1
         else:
            break
      else:
         total -= counter
         break
   return total

def modelAnswer():
   return
def main():
   N = int(input())
   s = input()
   t = input()
   print(myAnswer(N,s,t))
if __name__ == '__main__':
   main()

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

using namespace std;

int main(){
    int r,g,b,k;
    cin>>r>>g>>b>>k;
        while(r >= g && k){
            g *= 2;
            k--;
        }
        while(g >= b && k){
            b *= 2;
            k--;
        }
    if(b > g && g > r){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ll n,a,b; cin >> n >> a >> b;
  ll c = (n/(a+b))*a;
  c += min(n%(a+b),a);
  cout << c << endl;
  return 0;
}


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

//using namespace std;

int64_t gcd(int64_t a, int64_t b)
{
    if (a < b) {
        int64_t tmp = a;
        a = b;
        b = tmp;
    }

    int64_t r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

int main(int argc, char* argv[]) {
    int64_t N, M;

    std::cin >> N >> M;

    int64_t res = 1;
    for (int64_t i = 1; i * i < M; i++) {
        if (M % i == 0) {
            if (i <= M / N) {
                res = std::max(res, i);
            }
            if (i >= N) {
                res = std::max(res, M / i);
            }
        }
    }

    std::cout << res << std::endl;

    return 0;
}

Measured memory_bytes: 256