akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1e9+7;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
#define fs first
#define sc second


const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
template<typename T>
T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T>
T ngcd(vector<T> a){
    T res;
    res = a[0];
    for(int i = 1; i < a.size() && res != 1; i++) {
        res = gcd(a[i], res);
    }
    return res;
}
 
template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
T nlcm(vector<T> numbers) {
    T res;
    res = numbers[0];
    for (int i = 1; i < numbers.size(); i++) {
        res = lcm(res, numbers[i]);
    }
    return res;
}

// 割り算の切り上げ処理
template<typename T>
T round_up(T a, T b) {
  return (a + b - 1) / b;
}

// 約数列挙
template<typename T>
vector<T> calc_divisor(T n) {
   vector<T> res;
   for (T i = 1LL; i*i <= n; ++i) {
       if (n % i == 0) {
           res.push_back(i);
           T j = n / i;
           if (j != i) res.push_back(j);
       }
   }
   sort(res.begin(), res.end());
   return res;
}

// 素数判定
template<typename T>
bool isPrime(T x){
    T i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


using pint = pair<int, int>;
using pll = pair<ll, ll>;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};




int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    int a, b;
    cin >> a >> b;
    if(a % 2 != b % 2) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << (a + b) / 2 << endl;
    }
}


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

int n,b[10];

bool dfs(int l, int r, int c)
{
	if(c==10) return true;

	if(l<b[c])
	{
		if(dfs(b[c],r,c+1)) return true;
	}
	if(r<b[c])
	{
		if(dfs(l,b[c],c+1)) return true;
	}
	return false;
}


int main()
{
	cin >> n;
	while(n--)
	{
		for(int i=0; i<10; i++) cin >> b[i];
		cout << ( dfs(0,0,0)? "YES":"NO" ) << endl;
	}
}

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


int n, w;
int weight[110], value[110];
ll dp[100100];

int main() {
  cin >> n >> w;
  rep(i,n) cin >> weight[i] >> value[i];
  ll sum = 10;
  rep(i,n) sum += value[i];
  rep(i,sum) dp[i] = INF;
  dp[0] = 0;
  rep(i,n) {
    for(int j = sum; j >= value[i]; j--) {
      dp[j] = min(dp[j],dp[j-value[i]]+weight[i]);
    }
  }
  int ans = 0;
  rep(i,sum) {
    if(dp[i] <= w) ans = i;
  }
  cout << ans << endl;
  return 0;
}

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

int main(void)
{	
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	
	double dist = sqrt(pow((x2 - x1), 2) + pow((y2 - y1), 2));
	
	cout << fixed << dist << endl;
	
	return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  vector<int> A(N+1),B(N);
  A.at(N)=200001;
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  int j=0,k=0;
  for(int i=1; i<=N; i++){
    while(j<N && A.at(j)==i){
      k++;
      j++;
    }
    B.at(i-1)=k;
    k=0;
  }
  sort(B.begin(), B.end());
  for(int i=0; i<N-K; i++){
    k+=B.at(i);
  }
  cout << k << endl;
}

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

using namespace std;

vector<vector<int>> v;


int main(){
    string s;
    int m = 0;
    while(cin >> s){
        vector<int> a;
        while(s.size() != 0){
            if(s.find(",") == -1){a.push_back(stoi(s)); break;}
            else {a.push_back(stoi(s.substr(0, s.find(",")))); s = s.substr(s.find(",")+1);}
        }
        m = max(m, (int)a.size());
        if(a.size() < m){
            int p = a.size();
            for(int i=0; i < m-p; i++) a.push_back(0);
            for(int i=p-1; 0 <= i; i--) a[i+(m-p)] = a[i];
            for(int i=0; i < m-p; i++) a[i] = 0;
        }
        while(a.size() < 100) a.push_back(0);
        v.push_back(a);
    }
    int memo[110][110] = {0};
    memo[0][0] = v[0][0];
    for(int i = 1; i < v.size(); i++){
        for(int j = 0 ; j < v[i].size(); j++){
            memo[i][j] = max(memo[i][j], v[i][j] + memo[i-1][j]);
            if(j != 0) memo[i][j] = max(memo[i][j], v[i][j] + memo[i-1][j-1]);
        }
    }
    int ret = 0;
    for(int i=0; i < 110; i++){
        ret = max(ret, memo[v.size()-1][i]);
    }
    cout << ret << endl;
}

Measured memory_bytes: 1320
package main

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

type shop struct {
	a int
	b int
}

func main() {
	N, M := ReadInt(), ReadInt()
	shops := make([]shop, N)
	for i := 0; i < N; i++ {
		shops[i].a, shops[i].b = ReadInt(), ReadInt()
	}

	sort.Slice(shops, func(i, j int) bool {
		return shops[i].a < shops[j].a
	})

	ans := 0
	for i := 0; M > 0; i++ {
		c := Min(M, shops[i].b)
		M -= c
		ans += c * shops[i].a
	}
	fmt.Println(ans)
}

func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var sc = bufio.NewScanner(os.Stdin)

func init()        { sc.Buffer(make([]byte, 256), 1e9); sc.Split(bufio.ScanWords) }
func Read() string { sc.Scan(); return sc.Text() }

func ReadInt() int {
	v, e := strconv.Atoi(Read())
	if e != nil {
		panic(e.Error())
	}
	return v
}


Measured memory_bytes: 5080
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    int a;
    cin >> a;
    A[i] = a - 1;
  }

  int answer = 0;
  rep(i, N) {
    if(A[A[i]] == i) ++ answer;
  }
  cout << answer / 2 << endl;
  return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

ll n;
int main() {
    cin >> n;
    ll m = n;
    int sum = 0;
    while (n) {
        int r = n % 10;
        sum += r;
        n /= 10;
    }
    if (m % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
    long long a,b,c,count;
    while(cin>>a>>b>>c)
    {
        count=b/c-a/c;
        if(a%c==0) cout<<count+1<<endl;
        else cout<<count<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAX_N 100001
int par[MAX_N];
int rank[MAX_N];

struct operate{char op;int num;};

void init(int n){
	int i;
	for(i=0;i<n;i++){
		par[i] = i;
		rank[i] = 0;
	}
}

int M_find(int x,int mark[]){
	if(mark[x]==1){
		return x;
	}else{
		return M_find(par[x],mark);
	}
}

void make_tree(int x,int y){
	if(x==y){
		return ;
	}
	else par[x]=y;
}

int main(){
	int i,n,num_q,p_node;
	int mark[MAX_N];
	struct operate ope;
	long long int sum;

	while(1){
		scanf("%d %d",&n,&num_q);
		if(n==0)break;
		init(MAX_N);
		sum=0;

		for(i=2;i<=n;i++){
			mark[i]=0;
			scanf("%d",&p_node);
			make_tree(i,p_node);
		}
		getchar();
		mark[1]=1; i=0;
		for(i=0;i<num_q;i++){
			scanf("%c %d",&ope.op,&ope.num);
			getchar();
			if(ope.op=='Q')sum+=M_find(ope.num,mark);
			if(ope.op=='M')mark[ope.num]=1;
		}
		printf("%lld\n",sum);
	}
	return 0;
}

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

int main(){
	int n,a,b,c;
	string s;
	cin >> n;
	if(n==1){
		cout << "Hello World" ;
	}
	else{
		cin >> a >> b;
		c=a+b;
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import math

m = int(input())


s = []
for i in range(math.floor(math.sqrt(m))+3):
	if m%(i+1)==0:
		if (i+1) not in s:
			s.append(i+1)
		if m//(i+1) not in s:
			s.append(m//(i+1))
s.sort()
x =0
for i in range(len(s)):
    if m//s[i]>s[i]+1:
        x += m//s[i]-1
print(x)

Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define uint unsigned int
#define ull  unsigned long long
typedef string str;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define ins insert
#define all(x) (x).begin(), (x).end()
#define fr(i, n) for(int i = 0; i < n; i++)
#define rall(x) (x).rbegin(), (x).rend()
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
const int INF = 1e9 + 5;
 

void solve(){
   string s;
   cin >> s;
   fr(i , s.size()){
       if(s[i] == '7'){
           cout  << "Yes";
           return;
       }
   }
   cout << "No";
    
}
 
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3652
import sys
from functools import reduce
from operator import add
input = sys.stdin.readline

def main():
    N = int(input())
    X = list(map(int, input().split()))

    ans = float('INF')
    for i in range(1, 101):
        power = reduce(add, map(lambda x: (x - i) ** 2, X))

        ans = min(ans, power)

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3572
S=input()
if (1 <= int(S[:2]) <= 12) and (1 <= int(S[2:]) <= 12):
    print("AMBIGUOUS")
elif 1 <= int(S[:2]) <= 12:
    print("MMYY")
elif 1 <= int(S[2:]) <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        long[] a = new long[N];
        StringBuilder first = new StringBuilder();
        StringBuilder last = new StringBuilder();
        long sum = 0;
        a[0] = Long.parseLong(sc.next());
        for(int i=1; i<N; i++) {
            a[i] = Long.parseLong(sc.next());
            if(N % 2 == 0) {
                if(i % 2 == 0) last.append(" "+a[i]);
                else {
                    StringBuffer sb = new StringBuffer(String.valueOf(a[i]));
                    first.append(" "+sb.reverse().toString());
                }
            }else {
                if(i % 2 == 1) first.append(" "+a[i]);
                else {
                    StringBuffer sb = new StringBuffer(String.valueOf(a[i]));
                    last.append(" "+sb.reverse().toString());
                }
            }
        }
        StringBuilder ans = new StringBuilder();
        if(N % 2 == 0) {
            ans.append(first.reverse());
            ans.append(a[0]);
            ans.append(last);
        }else {
            ans.append(last.reverse());
            ans.append(a[0]);
            ans.append(first);
        }
        System.out.println(String.valueOf(ans));
    }   
}


Measured memory_bytes: 83020
#include <bits/stdc++.h>
#define int long long int
#define all(v) v.begin(),v.end()
#define ov(v) for(int i=0;i<(v).size();i++)cout<<v[i]<<" ";cout<<endl;
#define N 10000
using namespace std;
void solve()
{
	int n,x,t;
	cin>>n>>x>>t;
	int u = n/x;
	if(n%x !=0)u++;
	cout<<u*t<<endl;

}
signed main() 
{
	// int t;
	// cin>>t;
	// while(t--)
	solve();
	return 0; 
}

Measured memory_bytes: 3620
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll to, cost;
	bool operator<(const edge& right) const {
		return cost == right.cost ? to < right.to : cost < right.cost;
	}
};
struct point {
	ll x, y;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

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

int main() {
	ll a, b, h;
	cin >> a >> b >> h;
	wrln((a + b)*h / 2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cstdio>
#include <map>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

typedef complex<double> P;

// ??????
double dot(const P& a, const P& b) {
    return real(conj(a)*b);
}

// ??????
double cross(const P& a, const P& b) {
    return imag(conj(a)*b);
}

// ???p2?????????p0, p1???????????´???????°???±?????????
P projection(const P& p0, const P& p1, const P& p2) {
    // ???????????????????????´???
    P vec1 = p1 - p0;
    P vec2 = p2 - p0;
    return p0 + vec1 * dot(vec1, vec2) / dot(vec1, vec1);
}

// ???p0, p1???????????´??????????§°?????¨????????????p2??¨????§°??????
P reflection(const P& p0, const P& p1, const P& p2) {
    P proj = projection(p0, p1, p2);
    return proj - (p2 - proj);
}

int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;                               // a--c--b on line
}

// // ????????¨???P??¨??????????????????????????¢
// double norm(const P& a, const P& b) {
//     return dot(
//     return real(conj(a)*b);
// }

int main(){
    double x0, y0, x1, y1;
    int Q;

    cin >> x0 >> y0 >> x1 >> y1;
    
    P p0(x0, y0);
    P p1(x1, y1);

    cin >> Q;
    REP(q, Q) {
        double x2, y2;
        cin >> x2 >> y2;
        P p2(x2, y2);
        auto ret = ccw(p0, p1, p2);
        map<int, string> table{
            {+1, "COUNTER_CLOCKWISE"},
            {-1, "CLOCKWISE"},
            {+2, "ONLINE_BACK"},
            {-2, "ONLINE_FRONT"},
            {0, "ON_SEGMENT"}
        };
        cout << table[ret] << endl;
    }
}

Measured memory_bytes: 1260
//floyd
#include<vector>
#include<list>
#include<deque>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<iostream>
#include<limits>
#include<utility>

#define c11
#ifdef c11
#include<unordered_set>
#include<unordered_map>
#endif

using namespace std;
typedef long long ll;
#define ull unsigned long long
#define PI acos(-1.0)
#define eps 1e-12
#define initz(x) memset(x,0,sizeof(x))
#define initm(x) memset(x,0x7f,sizeof(x))
#define forn(i, n) for(int i = 0; i < (int) n; ++i)
#define for1(i, n) for(int i = 1; i <= (int) n; ++i)
#define fore(i, l, r) for(int i = (int) l; i <= (int) r; ++i)
#define rforn(i, n) for(int i = (int) n - 1; i>= 0; --i)
#define fi first
#define se second

int dx[4] = {1, 0 , -1, 0};
int dy[4] = {0, 1 , 0, -1};

const int INF = 0x3f3f3f3f;
const int MAX_N = 30;
const int MAX_M = 5000;

typedef pair<int, int> P;

int d[MAX_N][MAX_N];
int m;

void floyd() {
  for (int k = 0; k < m; ++k) {
    for (int i = 0; i < m; ++i) {
      for (int j = 0; j < m; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int n, a, b, c;
  while (scanf("%d", &n) != EOF && n) {
    memset(d, 0x3f, sizeof(d));
    m = 0;
    while (n--) {
      scanf("%d%d%d", &a, &b, &c);
      d[a][b] = d[b][a] = c;
      m = max(m, max(a + 1, b + 1));
    }
    floyd();
    int ans, p, tmp;
    p = 0;
    ans = INF;
    for (int i = 0; i < m; ++i) {
      tmp = 0;
      for (int j = 0; j < m; ++j) {
        if (i == j) continue;
        tmp += d[i][j];
        if (tmp >= INF) break;
      }
      if (tmp < ans) {
        ans = tmp;
        p = i;
      }
    }
    printf("%d %d\n", p, ans);
  }
  return 0;
}



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

int main() {
    int n, k;
    int x[101000];
    int ans = INT_MAX;
    
    cin >> n >> k;
    
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    
    for (int i = 0; i < (n - (k - 1)); i++) {
        if ((x[i] < 0) && (x[i + (k - 1)] < 0)) {
            ans = min(ans, -x[i]);
        }
        else if (x[i] < 0) {
            ans = min(ans, -x[i] + x[i + (k - 1)] + min(-x[i], x[i + (k - 1)]));
        }
        else {
            ans = min(ans, x[i + (k - 1)]);
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
    int N;
    cin >> N;
    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++) cin >> A[i];
    priority_queue<P> Q;
    for(int i=0;i<N;i++){
        cin >> B[i];
        Q.push({B[i],i});
    }
    auto getl = [&](int i){
        return (i-1+N)%N;
    };
    auto getr = [&](int i){
        return (i+1)%N;
    };
    ll ans = 0;
    while(!Q.empty()){
        P now = Q.top(); Q.pop();
        ll sum = B[getl(now.second)]+B[getr(now.second)];
        if(now.first<sum) continue;
        if(now.first%sum>=A[now.second]){
            ans += now.first/sum;
            B[now.second] %= sum;
        }else if((now.first-A[now.second])/sum!=0){
            ans += (now.first-A[now.second])/sum;
            B[now.second] -= (now.first-A[now.second])/sum*sum;
        }else continue;
        if(B[now.second]>A[now.second]) Q.push({B[now.second],now.second});
    }
    for(int i=0;i<N;i++) if(A[i]!=B[i]){
        cout << -1 << endl;
        return 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 9584
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;
use std::vec::Vec;

fn main() {
    let stdin = stdin();
    let mut scan = InputScanner::new(stdin.lock(),256);

    let n:usize = scan.next();

    let mut xl:Vec<(usize,usize)> = (0..n).map(|_| (scan.next(),scan.next())).collect::<Vec<(usize,usize)>>();

    xl.sort_by(|a,b| (a.0+a.1).cmp(&(b.0+b.1)));

    let mut count = 0;

    let mut cur = 0;

    for xl in &xl {
        if cur == 0 || cur as i64 <= xl.0 as i64 - xl.1 as i64 {
            count += 1;
            cur = xl.0 + xl.1;
        }
    }

    println!("{}",count);
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}



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

using namespace std;

char j_s_board[10][10];
int idx, width;

int jtos(string jfen)
{
    std::vector<char> board[10];
    int len = jfen.length();
    idx = 0;
    width = 0;
    for (int i = 0; i < len; i++)
    {
        if (jfen[i] == '/')
            idx++;
        else
        {
            if (jfen[i] == 'b')
            {
                board[idx].push_back('b');
                width++;
            }
            else
            {
                int j = jfen[i] - '0';
                for (int k = 0; k < j; k++)
                {
                    board[idx].push_back('.');
                    width++;
                }
            }
        }
    }
    for (int i = 0; i < idx + 1; i++)
        for (int j = 0; j < width / (idx + 1); j++)
            j_s_board[i][j] = board[i][j];
    return 0;
}

string stoj()
{
    string res = "";
    for (int i = 0; i < idx + 1; i++)
    {
        char num = '0'; //.?????£?¶?????????°
        for (int j = 0; j < width / (idx + 1); j++)
        {
            if (j_s_board[i][j] == '.')
                num++;
            else
            {
                if (num != '0')
                    res += num;
                res += 'b';
                num = '0';
            }
        }
        if (num != '0')
            res += num;
        if (i < idx)
            res += "/";
    }
    return res;
}

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

    string jfen;
    while (cin >> jfen, jfen != "#")
    {
        jtos(jfen);
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        char tmp = j_s_board[a - 1][b - 1];
        j_s_board[a - 1][b - 1] = j_s_board[c - 1][d - 1];
        j_s_board[c - 1][d - 1] = tmp;
        string ans = stoj();
        cout << ans << endl;
    }
}


Measured memory_bytes: 3196
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IMAX 2147483647
#define LMAX 9223372036854775807
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define fi first
#define se second
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define eraseif(vec,condition_VAR) vec.erase(remove_if(all(vec),[&](auto VAR){return condition_VAR;}),vec.end())
#define countif(vec,condition_VAR) count_if(all(vec),[&](auto VAR){return condition_VAR;})
#define replaceif(vec,condition_VAR,n) replace_if(all(vec),[&](auto VAR){return condition_VAR;},n)
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_VAR) for_each(all(vec),[&](auto&VAR){VAR=calc_VAR;});
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}
template<class C>int binarysearch(vector<C> vec,C n,char c){int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;while(right-left>1){int mid=left+(right-left)/2;bool OK=vec[mid]*getmin>=n*getmin;if(outleft==OK) left=mid;else right=mid;}return outleft?left:right;}


// #define int int64_t
// #define double long double


// map,makepair



signed main(){
  IOS;

  in(string,s,t);
  int ss=si(s);
  string ans="No";
  fou(i,0,ss){
    bool flag=true;
    fou(j,0,ss){
      if(s[j]!=t[j]) flag=false;
    }
    if(flag) {ans="Yes";break;}
    rotate(s.begin(),s.begin()+1,s.end());
  }
  out(ans);

}

Measured memory_bytes: 256
import math

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

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

koubai = 1
for i in range(N):
    koubai = lcm(koubai, a[i])

# f = [0 for i in range(koubai)]

# for i in range(len(f)):
#     for j in range(N):
#         f[i] += i % a[j]

ans = 0
for i in range(N):
    ans += (koubai-1) % a[i]

print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int a = 0;
        for (int i = 0; i < m; i++) {
            a+=scanner.nextInt();
        }
        System.out.println(Math.max(-1,n-a));
    }
}


Measured memory_bytes: 46588
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		List<Integer> d = new ArrayList<>();
		int answer = 1;

		for (int i = 0; i < N; i++) {
			d.add(sc.nextInt());
		}

		Collections.sort(d);

		for (int i = 0; i < N - 1; i++) {
			if (d.get(i) < d.get(i + 1)) answer++;
		}

		System.out.println(answer);
	}
}


Measured memory_bytes: 23124
h, w = map(int, input().split())
l = []
r = []

for i in range(h):
    ls = list(input())
    if "#" in ls:
        l.append(ls)
        

s = [0]*w

for i in range(len(l)):
  for j in range(w):
    if l[i][j] == "#":
      s[j] = 1  

for i in range(len(l)):
  ans = ""
  for j in range(w):
    ans += l[i][j]*s[j]
  print(ans)



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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = rbegin(s); i != rend(s); ++i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e18);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e18;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.ne(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }
template<class A, int N, class T>
void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

ll n, a, b;
void solve() {
    cin >> n >> a >> b;

    if (n<a + b - 1 || n>a* b) { cout << -1 << endn; return; }

    vector<ll> x;
    map<ll, int> mp;
    rep(i, b) {
        auto e = min(max(0LL, n - b - (a - 1) * i), a - 1) + 1;
        rep(j, e) {
            auto val = b - i + j * b;
            x.push_back(val);
            mp[val] = 0;
        }
    }

    int cnt = 1;
    for (auto& v : mp) v.second = cnt++;
    for (auto& v : x) cout << mp[v] << " ";
    cout << endn;
}

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


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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int S=0;
  for (int i=0; i<N-1; i++) {
    S+=a[i+1]-a[i];
  }
  cout << S << endl;
}

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

int main(){
  int n,m,a,s[100];
  pair<int,int> p[100];

  while(cin >> n >> m,n||m){
    for(int i=0;i<m;i++)s[i] = 0;
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	cin >> a; s[j] += a;
      }
    }
    
    for(int i=0;i<m;i++){
      p[i] = make_pair(-s[i],i+1);
    }

    sort(p,p+m);

    for(int i=0;i<m;i++){
      cout << p[i].second << (i!=m-1?" ":"\n");
    }
  }
}

Measured memory_bytes: 1160
// /*
// power code taken from geeks for geeks
// */

#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 100000000
#define MAX_N 200001
using namespace std;
typedef long long ll;
typedef long double ld;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}


struct p_str{
    ll x, y;
};

bool comp(p_str  &a, p_str &b){
    if(a.x==b.x){
        return a.y>b.y;
    }
    return a.x<b.x;
}

void swap(ll& s1, ll &s2){
    ll temp=s1;
    s1=s2;
    s2=temp;
}
ll gcd(ll a, ll b){
    if(b==0){
        return a;
    }
    return gcd(b, a%b);
}

ll _f(ll n){
    // calculate last digit of factorial...
    ll i=1;
    ll ans=1;
    while(i<=n){
        ans=ans*i;
        if(ans%10==0){
            break;
        }
        i++;
    }
    return ans%10;
}

void solve(){
    ll n;
    cin>>n;
    if(n%10==3){
        cout<<"bon"<<endl;
        return;
    }
    ll d=n%10;
    if(d==0 || d==1 || d==6 || d==8){
        cout<<"pon"<<endl;
        return;
    }
    cout<<"hon"<<endl;
}


int main(){



    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t=1;


    // cin>>t;
    
    while(t--){
        

        solve();
    }
    return 0;
}


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

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define debugg(x) out << #x << " is " << x << "\n" ;
#define gcd(a , b) __gcd(a,b) ;
#define lssetbitindex(x) __builtin_ffs(x)-1 ;           // __builtin_ffs(x) = 1 + least significant 1-bit of x

using namespace std;

class BStringPalindrome {
public:
	void solve(std::istream& in, std::ostream& out) {
	    string s , d ;
	    in >> s ;
	    d = s ;
	    reverse(d.begin() , d.end()) ;
	    if(s != d){
	        out << "No\n" ;
	        return ;
	    }
	    string s1 = s.substr(0 , (s.size()-1) / 2) ;
	    string s2 = s1 ;
	    reverse(s2.begin() , s2.end()) ;
	    if(s1 != s2) {
	        out << "No\n" ;
	        return ;
	    }

        s1 = s.substr((s.size()+3)/2 , (s.size()-1) / 2) ;
        s2 = s1 ;
        if(s1 != s2) {
            out << "No\n" ;
            return ;
        }
        out << "Yes\n" ;
	}
};


int main() {
	BStringPalindrome solver;
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
def solve(Mi,i):
    if Mi == 0: return True
    if i < n and min(A[i:]) <= Mi <= sum(A[i:]):
        r1 = solve(Mi-A[i],i+1)
        if r1: return r1
        r2 = solve(Mi,i+1)
        if r2: return r2
n = input()
A = map(int,raw_input().split())
q = input()
M = map(int,raw_input().split())
for Mi in M:
    print "yes" if solve(Mi,0) else "no"

Measured memory_bytes: 6452
a1 =list( map(int,input().split()))
a2 =list( map(int,input().split()))
a3 =list( map(int,input().split()))
N = int(input())
flag = False
for i in range(N):
    num = int(input())
    for i in range(3):
        if num == a1[i]:
            a1[i] = 0
        if num == a2[i]:
            a2[i] = 0
        if num == a3[i]:
            a3[i] = 0
if sum(a1) == 0:
    flag = True
if sum(a2) == 0:
    flag = True
if sum(a3) == 0:
    flag = True

for i in range(3):
    if a1[i] + a2[i] + a3[i] == 0:
        flag = True

if a1[0] + a2[1] + a3[2] == 0:
    flag = True

if a1[2] + a2[1] + a3[0] == 0:
    flag = True

if flag == True:
    print('Yes')
else :
    print('No')

Measured memory_bytes: 3064
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;


int main(void) {
	int n,i;
	cin >> n;
	for (i = 1; ; i++) {
		if (i*i > n) {
			i--;
			break;
		}
	}
	cout << i*i<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

int main() {
  std::string s;
  std::cin >> s;
  if (s.length() < 2 || s.length() % 2 == 1) {
    std::cout << "No\n";
    return 0;
  }

  for (size_t i = 0; i < s.length(); i+=2) {
    auto s1 = s[i];
    auto s2 = s[i+1];
    if (!(s1 == 'h' && s2 == 'i')){
      std::cout << "No\n";
      return 0;
    }
  }

  std::cout << "Yes\n";

  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
x = 0
lis = []
for i in range(0,len(H)-1) :
    if H[i] - H[i+1] >=0:
        x += 1
    else:
        lis.append(x)
        x =0
lis.append(x)
print(max(lis))
                
  

Measured memory_bytes: 14224
a, b, c = map(int, input().split())
k = int(input())
ma = max(a,b,c)

if ma == a:
  print(a*(2**k)+b+c)
elif ma == b:
  print(b*(2**k)+a+c)
elif ma == c:
  print(c*(2**k)+a+b)


Measured memory_bytes: 3060
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,A,B;
	scan(N);scan(A);scan(B);
	printf("%d %d\n",min(A,B),max(0,A+B-N));
	return 0;
}


Measured memory_bytes: 256
#! /usr/bin/env python3

def main():
    N = int(input())
    L = sorted(map(int, input().split()))[::-1]
    a = b = c = 0
    while c < len(L):
        t = L[c]
        c += 1
        if a == t:
            break
        else:
            a = t
    while c < len(L):
        t = L[c]
        c += 1
        if b == t:
            break
        else:
            b = t
    print(a*b)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
#include <iostream>
using namespace std;
const int MOD = 1000000007;

long long modPow(long long a, long long n) {
    if (n == 1) return a;
    if (n % 2) {
        return a * modPow(a, n - 1) % MOD;
    } else {
        return modPow(a * a % MOD, n / 2);
    }
}

long long nCr(long long n, long long r) {
    long long X = 1, Y = 1;
    for (int i = 0; i < r; i++) {
        X *= (n - i);
        X %= MOD;
        Y *= (r - i);
        Y %= MOD;
    }
    return X * modPow(Y, MOD - 2) % MOD; 
}

long long sub(long long &a, long long b) {
    a -= b;
    if (a < 0) return a += MOD;
    return a;  
}

int main() {
    long long n, a, b; cin >> n >> a >> b;
    long long ans = modPow(2, n) - 1;
    sub(ans, nCr(n, a));
    sub(ans, nCr(n, b));
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int MAX_N = 16;
const int INF = 100000000;

VVI g;
VVI dp;
int n;

int tsp(int visited, int v) {
  int& res = dp[visited][v];
  if (res != -1) return res;

  if (visited == (1 << n) - 1) return 0;

  res = INF;

  rep(u, n) {
    if (visited & (1 << u)) continue;
    res = min(res,
      tsp(visited | (1 << u), u) + g[v][u]);
  }
  return res;
}

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

int solve(int w, int h) {
  vector<string> field(h);

  rep(i, h) cin >> field[i];

  vector<PII> pts;
  PII start;
  rep(i, h) rep(j, w) {
    char c = field[i][j];
    if (c == 'o') start = PII(j, i);
    if (c == '*') pts.push_back(PII(j, i));
  }
  pts.insert(pts.begin(), start);
  n = pts.size();

  g  = VVI(n, VI(n, INF));
  dp = VVI(1 << n, VI(n, -1));

  rep(pi, n) {
    PII startPt = pts[pi];
    queue<PII> que;
    VVI visited(h, VI(w));
    que.push(startPt);

    for(int d = 0; !que.empty(); d++) {
      int sz = que.size();
      rep(qi, sz) {
        PII pt = que.front();
        que.pop();
        int x = pt.first;
        int y = pt.second;
        visited[y][x] = true;

        rep(pj, n) {
          if (pt == pts[pj]) {
            g[pi][pj] = g[pj][pi] = d;
            break;
          }
        }

        rep(di, 4) {
          int nx = x + dx[di];
          int ny = y + dy[di];
          if (nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
          if (visited[ny][nx]) continue;
          if (field[ny][nx] == 'x') continue;
          visited[ny][nx] = true;
          que.push(PII(nx, ny));
        }
      }
    }
  }

  int ans = tsp(1, 0);
  if (ans == INF) ans = -1;
  return ans;
}

int main() {
  int w, h;
  while(cin >> w >> h, w || h) cout << solve(w, h) << endl;

  return 0;
}

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    string s; cin >> s;
    int ans = 0;
    REP(i, s.length())
    {
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A, B, C, a, b, c;
int ans = 0;
ll tmp;
ll tmp2;
int main(){
  cin.sync_with_stdio(false);
  cin >> A >> B >> C;
  a = A;
  b = B;
  c = C;
  while(true){
    if(A % 2 != 0 || B % 2 != 0 || C % 2 != 0 ){
      cout << ans << endl;
      break;
    }else{
      tmp = A;
      A = B / 2 + C / 2;
      tmp2 = B;
      B = tmp / 2 + C / 2;
      C = tmp2 / 2 + tmp / 2;
      ans++;
    }

    if((A == a && B == b && C == c) || (A == a && B == c && C == b) || (A == b && B == a && C == c) ||
      (A == b && B == c && C == a) ||  (A == c && B == a && C == b) || (A == c && B == b && C == a)){
        ans = -1;
        cout << ans << endl;
        break;
    }

  }







}

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

int main()
{
  list<int> ltiNumber;
  list<int>::iterator itlti;
  list<int>::iterator itltEND = ltiNumber.end();
  char acCommand[80];
  int iMaxCommand, iNumber;

  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++)
  {
    cin >> acCommand;
    if (acCommand[0] == 'i')
    {
      cin >> iNumber;
      ltiNumber.push_front(iNumber);
    }
    else if (acCommand[6] == 'F')
      ltiNumber.pop_front();
    else if (acCommand[6] == 'L')
      ltiNumber.pop_back();
    else if (acCommand[0] == 'd')
    {
      cin >> iNumber;
      for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti)
        if (*itlti == iNumber)
        {
          ltiNumber.erase(itlti);
          break;
        }
    }
  }

  int i = 0;
  for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti)
  {
    if (i++) cout << " ";
    cout << *itlti;
  }
  cout << endl;

  return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,t,r[300010],c[300010],num=0,num2=0,num3=0;
vector <pii> v,v2,in;

bool cmp(pii a,pii b)
{
	return a>b;
}

int main()
{
	cin>>n>>m>>t;
	int x,y;
	rep(i,t)
	{
		scanf("%d%d",&x,&y);
		x--;
		y--;
		r[x]++;
		c[y]++;
		in.pb(mpr(x,y));
	}
	rep(i,n) v.pb(mpr(r[i],i));
	rep(i,m) v2.pb(mpr(c[i],i));
	sort(v.begin(),v.end(),cmp);
	sort(v2.begin(),v2.end(),cmp);
	rep(i,v.size())
	{
		if(v[i].fi==v[0].fi) num++;
		else break;
	}
	rep(i,v2.size())
	{
		if(v2[i].fi==v2[0].fi) num2++;
		else break;
	}
	rep(i,t) if(r[in[i].fi]==v[0].fi&&c[in[i].se]==v2[0].fi) num3++;
	if(num3==num*num2) cout<<v[0].fi+v2[0].fi-1<<endl;
	else cout<<v[0].fi+v2[0].fi<<endl;
	return 0;
}

Measured memory_bytes: 16328
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll int modd = 1000000007;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n;
    cin >> n;
    // dp[i][j] corresponds to probability of having j heads among first i coins
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1;
    double pi;
    for (int i = 1; i < n+1; i++)
    {
        cin >> pi;
        for (int j = 0; j <= i; j++)
        {
            if(j==0){
                dp[i][j] = (1-pi)*(dp[i-1][j]);
            }else{
                dp[i][j] = (pi * (dp[i-1][j-1])) + ((1-pi)*(dp[i-1][j]));
            }
        }
    }
    
    // for (int i = 0; i < n+1; i++)
    // {
    //     for (int j = 0; j < n+1; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    double sumAns = accumulate(dp[n].begin() + (n+1)/2, dp[n].end(), 0.0);
    cout.precision(10);
    cout << fixed << sumAns << endl;
}

Measured memory_bytes: 70656
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-x))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
Finline int lcm(int a,int b)
{
	return a*b/gcd(a,b);
}
int main()
{
	int n;
	read(n);
	printf("%d\n",lcm(n,360)/n);
	return 0;
}


Measured memory_bytes: 3544
// #pragma GCC optimize("03")
#include <bits/stdc++.h>
#define ll long long 
#define fi first
#define se second
#define mod 1000000007

using namespace std;

int n;
ll memo[3010][3010]; 
ll dp[3010];     
ll a[3010];
ll s;

ll getsum(int l, int r) {
    return dp[r] - dp[l - 1];
}

ll solve(int l, int r) {
    if (l == r)
        return a[l];
    if (memo[l][r] != 0)
        return memo[l][r];
    
    return memo[l][r] = max(a[l] + getsum(l + 1, r) - solve(l + 1, r), a[r] + getsum(l, r - 1) - solve(l, r - 1));
}

int main() {    
    // ifstream cin("tst.in");
    // ofstream cout("tst.out");
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    cin >> n;  
    for (int i = 1; i <= n; i++)
        cin >> a[i], dp[i] = a[i] + dp[i - 1]; 

    cout << 2 * solve(1, n) - getsum(1, n);
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  int ans = *max_element(vec.begin(), vec.end()) -
            *min_element(vec.begin(), vec.end());
  cout << ans << endl;
}


Measured memory_bytes: 256