akhauriyash/Code-Regression huggingface dataset:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3

n = int(input())
h = list(map(int, input().split()))

h[0] -= 1
for i in range(1, n):
    if h[i] - h[i - 1] >= 1:
        h[i] -= 1
    elif h[i] - h[i - 1] < 0:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14396
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#define inf 1e9+7
#define pb push_back
#define make make_pair
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
typedef pair<ll,ll> Pair;

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

const ll INF=99999999999999;
const ll MOD=1000000007;

using Edge = pair<ll,ll>;  //　1つ目は結んでいるノード、2つ目はその辺の重みを指す
using Graph = vector<vector<Edge> >;  //隣接リスト

void dijkstra(const Graph &G, vl &dist, ll s){  // sを始点とする最短経路
    priority_queue<Pair, vector<Pair>, greater<Pair> > que; //secondが頂点、firstがその頂点への暫定最小コストを表す
    dist[s] = 0;  //sへの距離は0
    
    que.emplace(0, s);
    
    while(!que.empty()){
        Pair p = que.top(); //キューから辺を取り出す
        que.pop(); //取り出した辺は破棄
        ll v = p.second;
        if(dist[v] < p.first) continue; //辺の行き先の距離が辺のコスト未満なら、そのまま
        for(auto e : G[v]){  //頂点vから出る各辺について
            if(dist[e.first] > dist[v] + e.second){  //辺Eを通るとコストが改善される場合
                dist[e.first] = dist[v] + e.second;  //更新
                que.emplace(Pair(dist[e.first], e.first));  //キューにその頂点を格納
            }
        }
    }
}

int main() {
    ll n;
    cin >> n;
    Graph g(n);
    vl dist(n,INF);
    rep(i,n-1){
        ll a,b,c;
        cin >> a >> b >> c;
        g[a-1].push_back(Edge(b-1,c));
        g[b-1].push_back(Edge(a-1,c));
    }
    dijkstra(g,dist,0);
    
    rep(i,n){
        if(dist[i]%2==0) cout << 0 << endl;
        else cout << 1 << endl;
    }
}





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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int cnt = 0;
  int cmin = 1e9;
  rep(i, n) {
    if(cmin > p[i]) {
      cmin = p[i];
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4024
l,r=map(int,input().split())
x=l//2019
y=l%2019
z=r//2019
w=r%2019
if x<z:
    print(0)
else:
    if y==0:
        print(0)
    else:
        ans=2020
        for i in range(y,w):
            for j in range(i+1,w+1):
                ans=min(ans,(i*j)%2019)
        print(ans)


Measured memory_bytes: 8912
a, b, c, x, y = map(int, input().split())
m = 0
if a + b < 2 * c:
    m += (a * x) + (b * y)
else:
    m += 2*min([x, y])*c
    if x - y < 0:
        m += min([(abs(x-y) * b), 2*abs(x-y) * c])
    else :
        m += min([(abs(x-y) * a), 2*abs(x-y) * c])
print(m)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

using ll = long long;

ll mod = 1000000007;

int main(int argc, char const *argv[]) {
	int n,m;
	std::cin >> n >> m;
	std::vector<std::vector<int>> v(m,std::vector<int> (2));
	for (size_t i = 0; i < m; i++) {
		std::cin >> v[i][1] >> v[i][0];
	}

	sort(v.begin(), v.end());


	std::vector<int> kill;
	for (size_t i = 0; i < v.size(); i++) {
		bool flag = true;
		for (size_t j = 0; j < kill.size(); j++) {
			if (v[i][1] < kill[j] && kill[j] <= v[i][0]) {
				flag = false;
				break;
			}
		}
		if (flag) {
			kill.push_back(v[i][0]);
		}

	}

	std::cout << kill.size() << '\n';
	return 0;
}


Measured memory_bytes: 5760
import java.util.Scanner;
public class Main {
    static boolean[] primeList = new boolean[1000000];
    public static void prime() {
        for(int i = 0; i < 1000000; i ++) primeList[i] = true;
        primeList[0] = false; primeList[1] = false;
        for(int i = 2; i * i < 1000000; i ++) if(primeList[i]) for(int j = i * i; j < 1000000; j += i) primeList[j] = false;
    }
    public static int solve(int n) {
        int m = 0;
        for(int i = 0; i <= n; i ++) if(primeList[i]) m ++;
        return m;
    }
    public static void main(String[] arg) {
        Scanner scan = new Scanner(System.in);
        prime();
        while(scan.hasNext()) {
            int n = scan.nextInt();
            System.out.println(solve(n));
        }
    }
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


void Main()
{
    int x,y,z;
    cin>>x>>y>>z;

    cout << z << " " << x << " " << y << endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;

itn N;
itn A[202020];
int B[202020];
int C[202020];


void solve() {
    int tmp = 0;
    FOR(N) {
        C[i] = B[i] * (B[i] - 1) / 2;
        tmp += C[i];
    }
    FOR(N) {
        int a = A[i];
        int b = B[a] - 1;
        int ans = tmp - C[a] + (b >= 1 ? b * (b - 1) / 2 : 0);
        cout << ans << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N) {
        cin >> A[i];
        A[i]--;
        B[A[i]]++;
    }


    solve();
    return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
int main() {
	int k, a, b, m, n;
	bool flag = false;
	cin >> k >> a >> b;
	m = a / k;
	n = k * m;
	for (int i = m; n <= b; i++) {
		n = k * i;
		if (n <= b && n >= a) {
			flag = true;
			break;
		}
	}
	if (flag) {
		cout << "OK" << endl;
	} else {
		cout << "NG" << endl;
	}
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


// ABC060B - Choose Integers
int main(){
  int A, B, C; // 100
  cin >> A >> B >> C;

  // total = (n + m + ...)A = xB + C が成立できるか
  // (xB + C) % A == 0
  bool can = false;
  for (int i = 0; i <= 100; ++i) {
    if ((i * B + C) % A == 0) {
      can = true;
      break;
    }
  }


  cout << (can ? "YES" : "NO") << endl;
  return 0;
}



Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
void solv() {

	int n,b;
	cin >> n >> b;
	int sum = 0;
	for (size_t i = 1; i <= n; i++)
	{
		sum += b + i - 1;
	}
	int res = 0;
	int abb = INF;
	for (size_t i = 1; i <= n; i++)
	{
		int t = sum - (b + i - 1);
		if (abb > abs(t - sum)) {
			res = t;
			abb = abs(t - sum);
		}
	}
	cout << res << endl;
}

int main() {
	//	COMinit();
	solv();

	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<char,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

ll cnt(string t,ll k){
	ll ret=0;
	int n=t.size();
	repi(i,1,n)if(t[i]==t[i-1])t[i]='A',ret+=k;
	return ret;
}

int main()
{
	string s;
	ll k;
	cin>>s>>k;
	ll ans=0;
	ll n=s.size();
	rep(i,n){
		if(s[i]!=s[0])break;
		if(i==n-1){
			cout<<n*k/2<<endl;
			return 0;
		}
	}
	vector<P> count;
	char c=s[0];
	int cnt=0;
	rep(i,n){
		if(s[i]==c)cnt++;
		else{
			count.emplace_back(P(c,cnt));
			cnt=1;
			c=s[i];
		}
		if(i==n-1)count.emplace_back(P(c,cnt));
	}
	if(s[0]==s[n-1]){
		for(auto x:count)ans+=x.second/2;
		ans*=k;
		int a=count[0].second, b=count[count.size()-1].second;
		ans-=(k-1)*(a/2+b/2-(a+b)/2);
	}else{
		for(auto x:count)ans+=x.second/2;
		ans*=k;
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;

int main()
{
    int n,k;
    string s;
    cin >> n >> k >> s;
    k--;
    if(s[k] == 'A') s[k] = 'a';
    if(s[k] == 'B') s[k] = 'b';
    if(s[k] == 'C') s[k] = 'c';
    cout << s << endl;
}

Measured memory_bytes: 384
# map(function, list) := list の中身をそれぞれ function に入れた結果を作って返してくれる関数
# 例: map(int, [1, 2, 3]) = [int(1), int(2), int(3)]
A, B, C = tuple(map(int, input().split()))

# A, B のそれぞれに、取り替える前の B, A を代入する
A, B = B, A

A, C = C, A

print(A, B, C)

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

class DWaterBottle {
public:
    double a,b,x;
    double getcap(double th){
        double h1 = b * cos(th);
        double h2 = a * sin(th);
        double cap = 0;
        if(h1 < h2){
            double len = h1 / sin(th);
            cap = b * len / 2;
        }else{
            double len1 = h2 / cos(th);
            cap = a * len1 / 2;
            double len2 = cap * 2 / h2;
            cap += len2 * (h1 - h2);
        }
        return cap;
    }
    void solve(std::istream& in, std::ostream& out) {
        in >> a >> b >> x;
        x /= a;
        const double PI = 4.0 * atan(1.0);
        double ok = 0, ng = PI/2;
        REP(_,100){
            double th = (ok + ng) / 2;
            (x <= getcap(th) ? ok : ng) = th;
        }
        out << (ok / PI * 180.0) << endl;
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    DWaterBottle solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    in.tie(0);
    out << std::fixed << std::setprecision(10);
    solver.solve(in, out);
    return 0;
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

LL K;

int main(){
	scanf("%lld" , &K);
	int N = 50;
	LL q = K / N;
	LL r = K % N;
	printf("%d\n" , N);
	repp(i,0,N){
		printf("%lld%c" , N - 1 + q - r + (i<r?N+1:0) , i+1==N?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int h, w;
typedef pair<int, int> P;
vector<string> maze(50);
vector<vector<int>> counts(50, vector<int>(50, INF));
queue<P> que;
int dy[4] = {0, 1, 0, -1};
int dx[4] = {1, 0, -1, 0};
int bfs()
{
        counts[0][0] = 0;
        que.push(P(0, 0));
        while (que.size())
        {
                P p = que.front();
                que.pop();
                if (p.first == h - 1 && p.second == w - 1)
                        break;
                for (int i = 0; i < 4; i++)
                {
                        int ny = p.first + dy[i];
                        int nx = p.second + dx[i];
                        if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] == '.' && counts[ny][nx] == INF)
                        {
                                que.push(P(ny, nx));
                                counts[ny][nx] = counts[p.first][p.second] + 1;
                        }
                }
        }
        return counts[h - 1][w - 1];
}

int main()
{
        cin >> h >> w;
        for (int i = 0; i < h; i++)
                cin >> maze[i];
        int black = 0;
        int all = h * w;
        for (int i = 0; i < h; i++)
        {
                for (int j = 0; j < w; j++)
                {
                        if (maze[i][j] == '#')
                                black++;
                }
        }
        int res = bfs();
        if (res == INF)
        {
                cout << -1 << endl;
        }
        else
        {
                cout << all - res - black - 1 << endl;
        }
}

Measured memory_bytes: 256
#include<iostream>
#define N 32768
long a[N],b[N],c[N]={},n,k,i=N;int main(){for(std::cin>>n>>k;--i;a[i]=i<n?i:n)b[i]=n/i;while(--k){for(;++i<N;)c[i]=c[i-1]+b[i];for(*a=c[n/--i];--i;a[i]=c[i])*a=b[i]=(*a+a[i]*(n/i-n/(i+1)))%0x3B9ACA07;}std::cout<<*a;}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
    while(1){
        int x, y, max = 0, min = 0;
        cin >> x >> y;
        if (x == 0 && y == 0)break;
        if (x > y) {min = y; max = x;}
        else{min = x; max = y;}
        cout << min << " " << max << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
def gcd(a, b):
    if a < b:
        a, b = b, a
    return b if a % b == 0 else gcd(b, a % b)

def solve(n, m, s, t):
    if n < m:
        s, t = t, s
        n, m = m, n
    if n % m == 0:
        l = n
    else:
        l = n * m // gcd(n, m)
    D = {}
    for i in range(n):
        D[i*l//n] = s[i]
    for i in range(m):
        k = i*l//m
        if (k in D) and (D[k] != t[i]):
            return -1
    return l

n, m = map(int, input().split())
s = input()
t = input()
print(solve(n, m, s, t))

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

int main()
{
    ll n;
    cin>>n;
    ll i,j;
    ll a[n],b[n],c[n-1];
    for(i=0;i<n;i++)
    {
       cin>>a[i];
    }
    for(i=0;i<n;i++)
    {
       cin>>b[i];
    }
    for(i=0;i<n-1;i++)
    {
       cin>>c[i];
    }
    ll ct=0;
    ct=b[a[0]-1];
    for(i=1;i<n;i++)
    {
       ct=ct+b[a[i]-1];
       if(a[i]==a[i-1]+1)
       {
          ct=ct+c[a[i-1]-1];
       }
    }
    cout<<ct;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,i,flag=0,flag2=0;
  scanf("%d",&a);
  int b[a];
  for(i=0;i<a;i++){
  	scanf("%d",&b[i]);
    if( b[i]%2==0){
        flag2++;
    if( b[i]%10==0 || b[i]%6==0)
        flag++;
  }
  }
  if(flag==flag2){
    printf("APPROVED");
    return 0;
  }
  	printf("DENIED");
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    ll dp[n+1][2];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        int d=s[i]-'0';
        for(int j=0;j<2;j++){
            for(int k=0;k<=(j?1:d);k++){
                dp[i+1][j||k<d]+=(k+1)*dp[i][j];
                dp[i+1][j||k<d]%=MOD;
            }
        }
    }
    cout<<(dp[n][0]+dp[n][1])%MOD<<endl;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
long long val;
constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
if (val < 0) val += MOD;
}
constexpr int getmod() { return MOD; }
constexpr Fp operator - () const noexcept {
return val ? MOD - val : 0;
}
constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
constexpr Fp& operator += (const Fp& r) noexcept {
val += r.val;
if (val >= MOD) val -= MOD;
return *this;
}
constexpr Fp& operator -= (const Fp& r) noexcept {
val -= r.val;
if (val < 0) val += MOD;
return *this;
}
constexpr Fp& operator *= (const Fp& r) noexcept {
val = val * r.val % MOD;
return *this;
}
constexpr Fp& operator /= (const Fp& r) noexcept {
long long a = r.val, b = MOD, u = 1, v = 0;
while (b) {
long long t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
val = val * u % MOD;
if (val < 0) val += MOD;
return *this;
}
constexpr bool operator == (const Fp& r) const noexcept {
return this->val == r.val;
}
constexpr bool operator != (const Fp& r) const noexcept {
return this->val != r.val;
}
friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
return os << x.val;
}
friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
if (n == 0) return 1;
auto t = modpow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

// 愚直計算による二項係数計算
mint com(long long n, long long r) {
mint res = 1;
for (long long i = 0; i < r; ++i) {
res *= (n-i);
res /= (i+1);
}
return res;
}

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

ll N,M;
cin >> N >> M;

if(abs(N-M) > 1) {
    cout << 0 << endl;
    return 0;
}

mint ans = 1;
rrep(i,N) {
    ans *= i;
}
rrep(i,M) {
    ans *= i;
}
if(N == M) ans *= 2;

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

Measured memory_bytes: 256
n = int(input())

ans = 0

for i in range(1, n+1):
    if i%2 == 0:
        continue
    
    cnt = 0
    for j in range(1, i+1):
        if i%j == 0:
            cnt += 1
    
    if cnt == 8:
        ans += 1
        
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int main()
{
	int num;
	scanf("%d", &num);
	map<ll, ll>ma;
	ll ans = 0;
	ll t = 0;
	for (int i = 0; i < num; i++)
	{
		ma[t]++;
		ll z;
		scanf("%lld", &z);
		t += z;
		ans += ma[t];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 12672
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if (cnt > 0) and (a[i]==(a[i-1]+1)):
        cnt += c[a[i-1]-1]

    cnt += b[a[i]-1]
    
print(cnt)

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

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

	if (a < b){
		cout << "a < b" << endl;
	}else if(a > b){
		cout << "a > b" << endl;
	}else if(a == b){
		cout << "a == b" << endl;
	}else{
		cout << "error" << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    int N; cin >> N;
    vector<int> W(N);
    for(int i=0; i<N; ++i) cin >> W[i];

    int ans=100;
    for(int i=1; i<N-1; ++i){
        int S1=0, S2=0;
        for(int j=0; j<=i; ++j) S1 += W[j];
        for(int j=i+1; j<N; ++j) S2 += W[j]; 

        int diff = abs(S1 - S2);

        if(ans>diff) ans = diff;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()	{
	long long a, b, k;
	cin >> a >> b >> k;
	if (b - a + 1 <= k * 2)  {
	    for (int i = a; i <= b; i++)    cout << i << endl;
	}   else {
	    b = b - k + 1;
	    for (int i = 1; i <= k; i++)    cout << a++ << endl;
	    for (int i = 1; i <= k; i++)    cout << b++ << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

#include <bits/stdc++.h>

using namespace std;

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

	int n;
	string s;
	cin >> n >> s;
	string t1 = s.substr(0, n / 2);
	string t2 = s.substr(n / 2);
	if (t1 == t2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

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

#define MAX 100005
#define INF 1001001001

int main(int, char**)
{
  int n, q;
  cin >> n >> q;
  vector< list<int> > a(n);

  vector<int> ans;
  rep(i,q) {
    int command;
    cin >> command;
    if (command == 0) {
      int t, x; cin >> t >> x;
      a[t].push_back(x);
    } else if (command == 1) {
      int t; cin >> t;
      int f = 0;
      for (auto e : a[t]) {
        if (f++) cout << " ";
        cout << e;
      }
      cout << endl;
    } else {
      int s, t; cin >> s >> t;
      a[t].splice(a[t].end(), move(a[s]));
    }
  }

  return 0;
}



Measured memory_bytes: 18616
#define ll long long
#define rep(i,n) for (int i=0;i<(n);i++)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<map>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;
ll c[SIZE];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	int a,b;


	rep(i,n){
		cin >> a >> b;
		c[a] += b;
	}


	for(int i = 1; i <=SIZE; i++){
			k -= c[i];
			if(k <=  0){
				cout << i << endl;
				break;
			}
	}
	return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;
LL sum[maxn];
LL N;
LL maxnn;

void init(){
    sum[0] = 0;
    int i = 1;
    while(true){
        sum[i] = sum[i-1] + i;
        if(sum[i] >= 1e9) break;
        ++i;
    }
    maxnn = i;
}

LL v(int l,int r){
    return sum[r] - sum[l];
}

int main()
{
    init();

    while(scanf("%lld",&N)&&N){
        int big = sqrt(2*N);
        int k,ll,rr;
        //int ans = 0;
        for( k = big; k >=0;k--){
            if((2*N) % (k+1) == 0){
                if(2*N/(k+1) >= k+2  && (2*N/(k+1) - k)%2 == 0){
                    ll = (2*N/(k+1) - k)/2;
                    rr = k + 1;
                    break;
                }
            }

        }


        cout << ll <<" "<< rr << endl;

    }

    return 0;
}



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

using namespace std;

typedef long long ll;

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

ll lcm(ll a, ll b)
{
  return a / __gcd(a, b) * b;
}

ll sum(ll n)
{
  return (n * (n + 1) / 2);
}

ll calc(int r) {
  ll res = 0;
  for(int p=0; p<=r; p++) {
    for(int q=0; q<=r; q++) {
      if(p + q >= r + min(p, q)) {
	res ++;
      }
    }
  }
  return res;
}

int main()
{
  ll L;
  while (cin >> L, L) {
    auto pf = prime_factor(L);
    ll res = 1;
    for (auto &p: pf) {
      res *= calc(p.second);
      //      res *= sum(p.second + 1);
    }    
    cout << res/2 + 1 << endl;
  }
  return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Y;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Y;
	Y/=1000;
	FOR(i,N+1) {
		x=Y-10*i;
		y=N-i;
		if((x-y)%4) continue;
		int a=(x-y)/4;
		int b=y-a;
		if(a<0 || a>y) continue;
		if(b<0 || b>y) continue;
		_P("%d %d %d\n",i,a,b);
		return;
		
	}
	_P("-1 -1 -1\n");
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int a,h,m,s;
    scanf("%d",&a);
    h=a/3600;
    a=a-h*3600;
    m=a/60;
    a=a-m*60;
    s=a;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

int f(int a){
	int ans = 0;
	while(0 < a){
		ans += a%10;
		a /= 10;
	}
	return ans;
}

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

	int num = 0;
	rep(i, n+1){
		int d = f(i);
		if(a <= d && d <= b)
			num += i;
	}
	cout << num << endl;
}

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


void solve()
{
	
ll n,x;
cin>>x>>n;


set<ll>p;
	
for(int i=0,e;i<n;i++)
{
	cin>>e;
	p.insert(e);
	
}
ll y=x;
while(1)
{
	if(p.count(max(x,0LL)) <1)
	{
		cout<<x;
		break;
	}
	if(p.count(y)<1)
	{
		cout<<y;
		break;
	}
	y++;
	x--;
}

}




int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 3568
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <random>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

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

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}



int main() {
	ll N;
	cin >> N;
  FOR(i,1,3501){
    FOR(j,1,3501){
      if(4*i*j-N*j-N*i<1)continue;
      ll k=N*i*j/(4*i*j-N*j-N*i);
      if((N*i*j)%(4*i*j-N*j-N*i)==0){
      print(i,j,k);
        return 0;
      }
    }
  }
  
	return 0;
}



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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    set<int> S;
    int X, N; cin >> X >> N;
    rep(i,N){
        int pi; cin >> pi;
        S.insert(pi);
    }
    rep(i,105){
        if(!S.count(X-i)){
            cout << X-i << endl;
            return 0;
        }else if(!S.count(X+i)){
            cout << X+i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3548
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    string s;
    int k,len,f=-1;
    cin>>k;
    cin>>s;
    len=s.length();
    for(int i=0;i<len;i++){
        if(i==k){
            f=i;
            break;
        }
        cout<<s[i];
    }
    if(f!=-1){
        cout<<"...";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int Max = max(a,max(b,c)), mi = min(a,min(b,c)), mid = a+b+c-Max-mi;
    int rsl = Max - mid;
    int n_ = rsl + mi;
    if((Max-n_)%2==0){
        cout << (Max-n_)/2+rsl << endl;
    }else{
        cout << (Max-n_)/2+2+rsl << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
s = list(input())

n = len(s)
a = (n-1)//2
b = (n+3)//2

ichi = list(reversed(s))
ni = s[0:a]
san = s[b-1:n+1]

rni = list(reversed(ni))
rsan = list(reversed(san))

if s == ichi and ni == rni and san == rsan:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define int ll
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int32_t main()
{
	prep();
	int k;
	string s;
	cin>>k>>s;
	int n=s.length();
	if(n<=k)
	{
		cout<<s;
	}
	else
	{
		cout<<s.substr(0,k)<<"...";
	}
	return 0;
}


Measured memory_bytes: 3656
// https://atcoder.jp/contests/dp/tasks/dp_c
#include <bits/stdc++.h>
using namespace std;



int main() {
  int N;
  cin>>N;
  int acts[N][3];
  for(int i= 0; i < N; ++i) 
    for(int j = 0; j < 3; ++j)
      cin >> acts[i][j];
      
  for(int i = 1; i < N; ++i) 
    for(int j = 0; j < 3; ++j) 
      acts[i][j] = max(acts[i-1][(j+1)%3], acts[i-1][(j+2)%3]) + acts[i][j];
      
  cout << max(max(acts[N-1][0], acts[N-1][1]), acts[N-1][2]) << endl;

}


Measured memory_bytes: 1408
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#define MOD (long long)1000000007
#define INF (long long)998244353
using namespace std;

int main(void){
    int n;
    int l,r;
    cin >> n;
    vector< pair<int,int> > a(n);
    vector<int> flag(n,1);
    for(int i=0; i<n; i++){
        cin >> l >> r;
        a[i].second=l-r; 
        a[i].first=l+r;
    }
       
    sort(a.begin(),a.end());
    int temp=-2000000000;
    int ans=0;
    for(int i=0; i<n; i++){
        if(temp<=a[i].second){
            temp=a[i].first;
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int n,s;

int digit_sum(int x, int b) {
  int r = 0;
  while (x > 0) {
    r += x % b;
    x /= b;
  }
  return r;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> n >> s;
  if (n < s) {
    cout << -1 << endl;
    return 0;
  }
  for (int b = 2; b * b <= n; b++) {
    int sum = digit_sum(n,b);
    if (sum == s) {
      cout << b << endl;
      return 0;
    }
  }
  if (n == s) {
    cout << n+1 << endl;
    return 0;
  }
  int ans = INF;
  for (int p = 1; p * p < n; p++) {
    int q = s - p;
    if (n - 1 >= 0 && (n - q) % p == 0) {
      int b = (n - q) / p;
      if (IN(p,0,b-1) && IN(q,0,b-1)) {
        CHMIN(ans,b);
      }
    }
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}

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

#define ll long long
#define mp make_pair
#define rep(i, a, b) for(int i = (a);i <= (b);i++)
#define per(i, a, b) for(int i = (a);i >= (b);i--)

using namespace std;

typedef pair<int, int> pii;
typedef double db;
const int N = 1e6 + 50;
char s[55][55];
int k[55], minn = N, pos;
int a[55][55], ans[55], l = 0;
int n, flag = 0, vis[55][55], f[55];
int main(){
//	freopen("input.in","r",stdin);
//	freopen("output.out","w",stdout);
	scanf("%d", &n);
	rep(i, 1, n) cin >> s[i];
	rep(i, 1, n){
		k[i] = strlen(s[i]);
		rep(j, 1, k[i]){
			a[i][j] = int(s[i][j-1]-'a'+1);	
		}
		if(k[i] < minn) minn = k[i], pos = i;
	}
	rep(i, 1, n) sort(a[i]+1, a[i]+k[i]+1);
	rep(i, 1, minn){
		int p = a[pos][i], o = 0, flag = 1;
		rep(j, 1, n){
			rep(u, 1, k[j]){
				if(vis[j][u] || f[j]) continue;
				if(a[j][u] == p) vis[j][u] = 1, f[j] = 1, o++;	
			}
			f[j] = 0;
		}
		if(o == n) flag = 0;
		if(!flag) ans[++l] = p;	
	}
	rep(i, 1, l){
		char s = (char)(ans[i]+'a'-1);
		cout << s;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
double pi = 2 * acos(0.0);
int main(){
        int a, b; cin >> a >> b;
        if (a >= 2) a = a*(a-1)/2;
        else a = 0;
        if (b >= 2) b = b*(b-1)/2;
        else b = 0;
        cout << a+b << endl;
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[110][110];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	for(int i=0;i<a;i++){
		int now=999999999;
		for(int j=0;j<b;j++){
			if(str[i][j]=='c')now=0;
			else now++;
			if(now>99999999)printf("-1");
			else printf("%d",now);
			if(j<b-1)printf(" ");
		}
		printf("\n");
	}
}

Measured memory_bytes: 1048
//https://atcoder.jp/contests/hitachi2020/tasks/hitachi2020_e
#include <bits/stdc++.h>
using namespace std;

char s[1050];

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i < (1 << n); i++) {
        for (int j = 1; j < (1 << m); j++)
            if ((i & -i) == (j & -j)) s[j] = '1';
            else s[j] = '0';
        puts(s + 1);
    }
}

Measured memory_bytes: 3704
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// Mod int
// cf. https://www.youtube.com/watch?v=1Z6ofKN03_Y
struct mint {
  ll x;
  mint(ll x = 0) : x((x + MOD) % MOD) {}
  mint& operator+= (const mint a) {
    if ((x += a.x) >= MOD) x %= MOD;
    return *this;
  }
  mint operator+ (const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint& operator-= (const mint a) {
    if ((x += MOD - a.x) >= MOD) x %= MOD;
    return *this;
  }
  mint operator- (const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint& operator*= (const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  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;
  }
};

const ll MAX_N = 1005;
// dp[i][j] .. number at (i-1,j-1)
mint dp[MAX_N][MAX_N];

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(r, h) {
    cin >> a[r];
  }

  if (a[0][0] != '#') {
    dp[1][1] = 1;
  }
  rep(r, h) rep(c, w) {
    if (a[r][c] != '#') {
      dp[r+1][c+1] += dp[r][c+1];
      dp[r+1][c+1] += dp[r+1][c];
    }
  }
  cout << dp[h][w].x << endl;
}


Measured memory_bytes: 9216
N = int(input())
h = list(map(int,input().split()))

dp = [0]*N

dp[1] = abs(h[1]-h[0])
for i in range(2,N):
  dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),dp[i-2] + abs(h[i] -h[i-2]))
print(dp[N-1])
         

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

int main() {
  string s, t;
  cin >> s >> t;
  
  long long i, j;
  vector<long long> x[26];
  for(i = 0; i < s.size(); i++){
    x[s.at(i) - 97].push_back(i + 1);
  }
  
  long long now = 0, cycle = 0, ans = 0;
  bool flag = true;
  for(i = 0; i < t.size(); i++){
    if(x[t.at(i) - 97].size() == 0){
      flag = false;
      break;
    }
    else{
      auto now_2 = upper_bound(x[t.at(i) - 97].begin(), x[t.at(i) - 97].end(), now);
      now = *upper_bound(x[t.at(i) - 97].begin(), x[t.at(i) - 97].end(), now);
      if(now_2 == x[t.at(i) - 97].end()){
        now = x[t.at(i) - 97][0];
        cycle++;
      }
    }
  }
  
  if(flag){
    ans = cycle * s.size() + now;
    cout << ans << endl;
  }
  else cout << -1 << endl;
}


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

#define endl "\n"
#define int long long int
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define mod (int)(1e9+7)
#define T int
#define pi pair<int,int>
#define umap unordered_map<T,T>
#define uset unordered_set<T>
#define ff first
#define ss second
#define vi vector<int>
#define pb push_back
#define all(v) v.begin(),v.end()
#define setbit(n) __builtin_popcount(n)
#define toUpper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define toLower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL)


int lcm(int a, int b)
{
	return (a / __gcd(a, b) * b);
}


int32_t main() {

	flash;
	cout << fixed;
	cout.precision(10);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t; cin >> t;
	int d; cin >> d;
	// int t=1;
	int ans = 0;
	while (t--) {
		int x, y;
		cin >> x >> y;

		int dis = pow(x, 2) + pow(y, 2);
		double z = sqrt(dis);
		if (z <= double(d))
			ans++;


	}
	cout << ans << endl;



	return 0;

}







Measured memory_bytes: 3704