akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

#define MAX 10001

typedef struct{
  int kazu;
  int hantei;
}weight;
  
int Kosu[MAX],Doko1[MAX],Doko2[MAX+1];

int main()
{
  int n,i,j,basho=0,min,min2,hazime,sumW=0,w1,w2,omosa,irekae,kosu,SUM=0;

  scanf("%d",&n);

  int seiretu[n];
  weight Wi[n];

  /*整列させてる(Counting Sort)*/
  
  for(i=0;i<n;i++)
    {
      scanf("%d",&Wi[i].kazu);
      Wi[i].hantei=0;
      Kosu[Wi[i].kazu]++;
    }
  
  for(i=0;i<10001;i++)
    {
      basho+=Kosu[i];
      Doko1[i]=basho-1;
      Doko2[i]=Doko1[i];
    }

  for(i=0;i<n;i++)
    {
      seiretu[ Doko1[Wi[i].kazu] ]=Wi[i].kazu;
      Doko1[Wi[i].kazu]--;
    }

  /*最小コストをもとめる*/

  min=seiretu[0];

  for(i=0;i<n;i++)
    {
      if(Wi[i].kazu!=seiretu[i]&&Wi[i].hantei==0)
	{
	  /*初期化*/
	  j=1001;
	  kosu=0;
	  sumW=0;
	  min2=10001;
	  omosa=Wi[i].kazu;
	  Wi[i].hantei=1;
	  
	  while(j!=i)
	    {
	      kosu++;
	      if(min2>omosa)min2=omosa;
	      sumW+=omosa;
	      for(j=0;j<n;j++)
		{
		  if(omosa==seiretu[j])break;
		}
	      Wi[j].hantei=1;
	      omosa=Wi[j].kazu;
	    }
	  
	  w1=sumW+( (kosu-2)*min2 );
	  w2=sumW+min2+( (kosu+1)*min );
	  
	  if(w1<w2)SUM+=w1;
	  else SUM+=w2;
	}
    }

  printf("%d\n",SUM);
	  
      
  return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <string>

#define MAX 70

using namespace std;

string f[MAX][MAX];
string memo[MAX][MAX];

int main(void)
{
	int w,h;
	int i1,i2;
	char c;
	string max;
	string temp1,temp2;

	while(1){
		cin>>w>>h;
		if(w+h==0) break;

		for(i1=0;i1<MAX;i1++){
			for(i2=0;i2<MAX;i2++){
				f[i1][i2]="-";
				memo[i1][i2]="";
			}
		}

		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				cin>>c;
				if(c<'0' || '9'<c) f[i1][i2]="-";
				else f[i1][i2]=c;
			}
		}
		
		max="";
		for(i1=1;i1<=h;i1++){
			for(i2=1;i2<=w;i2++){
				if(f[i1][i2]!="-"){

					temp1=memo[i1][i2-1];
					temp2=memo[i1-1][i2];

					if(temp1.size()>temp2.size()){
						memo[i1][i2]=temp1+f[i1][i2];
					}
					else if(temp1.size()==temp2.size()){
						if(temp1>temp2){
							memo[i1][i2]=temp1+f[i1][i2];
						}
						else memo[i1][i2]=temp2+f[i1][i2];
					}
					else memo[i1][i2]=temp2+f[i1][i2];

					if(memo[i1][i2][0]=='0') memo[i1][i2].erase(0,1);

					if(max.size()<memo[i1][i2].size()) max=memo[i1][i2];
					else if(max.size()==memo[i1][i2].size()) {
						if(max<memo[i1][i2]) max=memo[i1][i2];
					}
				}
				//memo[i1][i2]=max(f[i1][i2],memo[i1][i2-1]+f[i1][i2],memo[i1-1][i2]+f[i1][i2]);
				
			}
		}

		cout<<max<<endl;

	}
	return 0;
}

Measured memory_bytes: 1680
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;


int main(){
    long long int h, n;
    vector<long long int> v;
    cin >> n;
    long long int count = 0;
    
    long long int i, j, k;
    
    for(i = 0; i < n; i++){
        cin >> h;
        v.push_back(h);
    }

    while(1){
        i = 0;
        while(1){
            if(v[i] != 0){
                break;
            }else if(i == n-1){
                break;
            }else{
                i++;
            }
        }
        
        if(i == n-1){
            count += v[i];
            break;
        }
        
        j = i+1;
        while(v[j] != 0 && j != n){
            j++;
        }
        
        if(j == n){
            count++;
            for(k = i; k < j; k++){
                v[k]--;
            }
        }else{
            count++;
            for(k = i; k < j; k++){
                v[k]--;
            }
        }
    }
    
    cout << count << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<17;


int main(){
    int h,w;
    cin >> h >> w;
    int a[h][w];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    vector<P> ans;
    for (int i = 0; i < h; i++) {
        if(i%2==0){
            for (int j = 0; j < w; j++) {
                if(i==h-1&&j==w-1) continue;
                if(a[i][j]%2){
                    ans.pb(P(i,j));
                    if(j!=w-1){
                        a[i][j+1]++;
                        ans.pb(P(i,j+1));
                    }
                    else{
                        a[i+1][j]++;
                        ans.pb(P(i+1,j));
                    }
                }
            }
        }
        else{
            for (int j = w-1; j >= 0; j--) {
                if(i==h-1&&j==0) continue;
                if(a[i][j]%2){
                    ans.pb(P(i,j));
                    if(j!=0){
                        a[i][j-1]++;
                        ans.pb(P(i,j-1));
                    }
                    else{
                        a[i+1][j]++;
                        ans.pb(P(i+1,j));
                    }
                }
            }
        }
    }
    cout << ans.size()/2 << endl;
    for(int i=0;i<ans.size();i++){
        if(i%2==0) cout << ans[i].fs+1 << " " << ans[i].sc+1 << " ";
        else cout << ans[i].fs+1 << " " << ans[i].sc+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5104
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b = 0,c, n, k;
string s, t;
//cout<<<<endl;


bool anagram(string s,string t)
{
	sort(all(s)); sort(all(t));
	if (s == t)
		return 1;
	else
		return 0;
}

int main()
{
	int64_t x,a, b;
	cin >>x>> a >> b;
	if (abs(a-x)>abs(b-x))
		cout << "B" << endl;
	else
		cout << "A" << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n;
		int sum;
		int m;
		
		while(true){
			n = scan.nextInt();
			m = 1000;
			sum = 0;
			if(n == 0)break;
		
			m -= n;
		
			sum += m / 500;
			m %= 500;
		
			sum += m / 100;
			m %= 100;
			
			sum += m / 50;
			m %= 50;
		
			sum += m / 10;
			m %= 10;
			
			sum += m / 5;
			m %= 5;
		
			sum += m;
			
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 26064
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
const char sp = ' ';


using namespace std;

int main(void){
    ll H, W;
    cin>>H>>W;
    if(W==1 || H==1){ cout<<1<<endl; return 0;}
    if(W%2==0){
        cout<<W/2*H<<endl;
    } else{
        if(H%2==0){
            cout<<W*(H/2)<<endl;
        } else{
            cout<<W*(H/2)+W/2+1<<endl;
        }
    }
    return 0;
}


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

const std::vector<std::string> res{"AC", "WA", "TLE", "RE"};

void solve() {
    std::vector<int> cnt(4, 0);

    int n;
    std::cin >> n;
    while (n--) {
        std::string s;
        std::cin >> s;
        for (int i = 0; i < 4; ++i) {
            if (res[i] == s) ++cnt[i];
        }
    }

    for (int i = 0; i < 4; ++i) {
        std::cout << res[i] << " x " << cnt[i] << "\n";
    }
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3632
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

struct edge
{
    int to, cost;
};

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

    double T, X;
    cin >> T >> X;
    cout << T / X << endl;

    return 0;
}


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

long long D = 365, type = 26, inf = 1001001001;
vector<long long> C(type);
vector<vector<long long>> S(D,vector<long long>(type));

void input(){
  cin >> D;
  for(int i=0;i<type;i++) cin >> C[i];
  for(int i=0;i<D;i++){
    for(int j=0;j<type;j++){
      cin >> S[i][j];
    }
  }
  return;
}

long long calc(long long day, long long t, vector<long long> &last){
  long long score = S[day][t];
  for(int i=0;i<type;i++){
    score -= C[i] * (day - last[i]);
  }
  return score;
}

int main(){
  input();
  
  long long score = 0;
  vector<long long> last(type,-1);
  for(int i=0;i<D;i++){
    long long now = calc(i,0,last), ans = 0;
    for(int j=1;j<type;j++){
      long long x = calc(i,j,last);
      if(x>now){
        now = x;
        ans = j;
      }
    }
    
    last[ans] = i;
    score += now;
    cout << ans+1 << endl;
  }
  return 0;
}


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

int main() {
	int n,mid,x=1;
	cin>>n;
	mid=n/2;
	char s[n];
	cin>>s;
	if(n%2==1)
	cout<<"No";
	else
	{
		for(int i=0;i<mid;i++)
		{
			if(s[i]!=s[mid+i])
			{
				x=0;
				break;
			}
		}
		if(x)
		cout<<"Yes";
		else
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			int n = stdIn.nextInt();
			if(n==0){
				return;
			}
			int[][] d = new int[n][2];
			for(int i=0;i<n;i++){
				d[i][0] = stdIn.nextInt();
				for(int j=0;j<8;j++){
					int tmp = stdIn.nextInt();
					if(j%2==0){
						tmp*=60;
					}
					d[i][1]+=tmp;
				}
			}
			int[] cp = new int[n];
			for(int i=0;i<n;i++){
				cp[i] = d[i][1];
			}
			Arrays.sort(cp);
			for(int i=0;i<n;i++){
				if(cp[0]==d[i][1]){
					System.out.println(d[i][0]);
					break;
				}
			}
			for(int i=0;i<n;i++){
				if(cp[1]==d[i][1]){
					System.out.println(d[i][0]);
					break;
				}
			}
			for(int i=0;i<n;i++){
				if(cp[n-2]==d[i][1]){
					System.out.println(d[i][0]);
					break;
				}
			}
		}
	}
}

Measured memory_bytes: 13000
from collections import Counter
ss = input()

ans = 1000
candidates = set(ss)
for s in candidates:
    count = 0
    t = list(ss)
    while True:
        if len(set(t))==1:
            ans = min(ans, count)
            break
        t = [t[i] if t[i+1] != s else t[i+1] for i in range(len(t)-1)]
        count += 1
print(ans)

Measured memory_bytes: 3316
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [u64; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }
 
// https://practice.contest.atcoder.jp/tasks/practice_1
fn main() {
    input! { n: usize, s :chars }
    let mut b = 0;
    let mut r = 0;
    for &t in s.iter() {
        if t == 'B' { b += 1; } else { r += 1; }
    }
    if r > b { println!("{}", "Yes"); } else { println!("{}","No"); }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli divi(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
 
#define N 100003
 
map< pair<lli,lli> , bool > isBad;
 
int main(void)
{
  isBad[{0,0}] = isBad[{0,1}] =  isBad[{1,0}] = isBad[{2,1}] = isBad[{1,2}] = true;
  lli a,b;
  cin>>a>>b;
 
  if(abs(a-b)<=1 | isBad[{a,b}])
  {
  	cout<<"Brown";
  	return 0;
  }
  cout<<"Alice";
  return 0;
}
 
 
void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  if (n % k == 0) {
  	cout << 0 << endl;
  }else {
  	cout << 1 << endl;
  }
}

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

int main()
{
        while(true)
        {
                std::string s;
                std::cin >> s;

                if(s == "-")    break;

                int m;
                std::cin >> m;

                int sum = 0;
                for(int i=0;i<m;i++)
                {
                        int h;
                        std::cin >> h;
                        std::string str1 = s.substr(0,h);
                        std::string str2 = s.substr(h);
                        s = str2+str1;
                }

                std::cout << s << std::endl;
        }
}


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


int main(int argc, char *argv[])
{
    
 
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    char s;
    cin >> s;
    if (islower(s)) {
        cout << "a" << endl;
    } else {
        cout << "A" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll n,now=1,ans=0;
	cin >> n;
	vll a(n);
	rep(i,n) cin >> a[i];
	rep(i,n){
		if(a[i]==now){
			++now;
			++ans;
		}
	}
	cout << (ans==0?-1:n-ans) << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
//Range Sum Query
class Lz_segtree{
public:
    int n;
    ll e=0;
    ll init=0;
    vector<ll> dat,lz;
    Lz_segtree(int n_):n(n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2,0);
        lz.resize(n*2,e);
    }
    void update_f(ll& d,ll x){
        d+=x;
    }
    ll dat_propergate(ll l,ll r){
        return min(l,r);
    }
    void lz_propergatef(ll& l,ll& r,ll x){
        l+=x,r+=x;
    }
    void eval(int len,int k){
        if(lz[k]!=e) update_f(dat[k],lz[k]);
        if(len>1){
            lz_propergatef(lz[k*2+1],lz[k*2+2],lz[k]);
        }
        lz[k]=e;
    }
    //range [a,b)
    void update(int a,int b,int k,int l,int r,ll x){
        eval(r-l,k);
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            update_f(lz[k],x);
            eval(r-l,k);
        }
        else{
            update(a,b,k*2+1,l,(l+r)/2,x);
            update(a,b,k*2+2,(l+r)/2,r,x);
            dat[k]=dat_propergate(dat[2*k+1],dat[2*k+2]);
        }
    }
    //range [a,b)
    ll query(int a,int b,int k,int l,int r){
        eval(r-l,k);
        if(r<=a||b<=l) return INF;
        if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return dat_propergate(vl,vr);
        }
    }
    void update(int a,int b,ll x){
        return update(a,b,0,0,n,x);
    }
    ll query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q,c,s,t,x;
    cin>>n>>q;
    Lz_segtree seg(n);
    rep(i,q){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }
        else{
            cin>>s>>t;
            ll ans=seg.query(s,t+1);
            cout<<ans<<endl;
        }
    }
    return 0;
}



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

string S;

int main(){
	cin >> S;
	bool ok = false;
	long long ans = S[0] - '0';
	if(S[0] != '1')
		ok = true;
	for(long long i = 1; i < S.size(); i++){
		if(S[i] != '0')
			ok = true;
		ans += S[i] - '0';
	}
	if(!ok){
		cout << 10 << endl;
		return 0;
	}

	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
typedef  pair<int, int> iPair; 
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}

int main()
{
        ios_base::sync_with_stdio(false);
        int n;
        cin >> n;
        ll ans = 0;
        int b[n-1];
        int temp;
        for(int i=0;i<n-1;i++){
            cin >> b[i];
            if(i==0)ans+=b[i];
            else ans+=min(b[i],b[i-1]);
        }
        ans+=b[n-2];
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

void solve() {
    int n, k;
    cin >> n >> k;

    cout << n - k + 1 << "\n";
}

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

    solve();
    return 0;
}
 


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
def main():
    sys.setrecursionlimit(10 ** 7)
    inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; cnt = 0; ansli = []; tmpli = []; candili = []; stillset = set()
    eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
    dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
    def wi(): return list(map(int, sys.stdin.readline().split()))
    def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
    def ws(): return sys.stdin.readline().split()
    def i(): return int(sys.stdin.readline())
    def s(): return input()
    def s_list(): return list(input())
    def hi(n): return [i() for _ in range(n)]
    def hs(n): return [s() for _ in range(n)]#HeightString
    def mi(n): return [wi() for _ in range(n)]#MatrixInt
    def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
    def mip(n): return [wip() for _ in range(n)]
    def ms(n): return [ws() for _ in range(n)]
    def grid(n): return [s_list() for _ in range(n)]

    n = i()
    h = wi()

    for i in range(1, n):
        if h[i - 1] < h[i]:
            ans = max(ans, tmp)
            tmp = 0
        else:
            tmp += 1
    ans = max(ans, tmp)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 16660
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include<cassert>

#define repeat(i,n)     for(int i=0; i<(n); ++i)
#define repeat1(i,n)    for(int i=1; i<=(n); ++i)
#define range(i,l,r)    for(int i=(l); i<(r); ++i)

using namespace std;
typedef long long llint;
typedef vector<char> vc;

int iin();
llint   lin();
double  fin();

vector<vector<vector<int> > > memo;

void input(vector<vector<char> >& blocks, int h, int w) {
    char c;
    repeat(i, h) {
        repeat(j, w) {
            scanf("\n%c", &c);
            blocks[j][i] = c;
        }
    }
}

int snapcost(vc& col1, int h1, vc& col2, int h2, int ic) {
    int cost = 0;
    if(memo[ic][h1][h2] >= 0)   return memo[ic][h1][h2];
    repeat(i, min(h1, h2)) {
        if(h1 >= h2) {
            if(col1[h1-h2+i] == col2[i])    ++cost;
            memo[ic][h1-h2+i+1][i+1] = cost;
        }
        else {
            if(col2[h2-h1+i] == col1[i])    ++cost;
            memo[ic][i+1][h2-h1+i+1] = cost;
        }
    }
    return cost;
}

int cost2cols(vector<char> &col1, vector<char> &col2, int h, int ic) {
    vector<vector<int> > tbl(h+1, vector<int>(h+1));

    tbl[h][h] = 0;
    for(int i=h-1; i>=0; --i) {
        tbl[h][i] = tbl[h][i+1] + snapcost(col1, h, col2, i+1, ic);
        tbl[i][h] = tbl[i+1][h] + snapcost(col1, i+1, col2, h, ic);
        for(int j=i+1; j<h; ++j) {
            tbl[h+i-j][j] = min(
                tbl[h+i-j+1][j] + snapcost(col1, h+i-j+1, col2, j, ic),
                tbl[h+i-j][j+1] + snapcost(col1, h+i-j, col2, j+1, ic)
            );
        }
    }
    for(int i=h-1; i>=0; --i) {
        for(int j=0; j<=i; ++j) {
            tbl[i-j][j] = min(
                tbl[i-j+1][j] + snapcost(col1, i-j+1, col2, j, ic),
                tbl[i-j][j+1] + snapcost(col1, i-j, col2, j+1, ic)
            );
        }
    }
    return tbl[0][0];
}

llint solve(vector<vector<char> >& blocks, int h, int w) {
    llint cost = 0;

    memo.resize(w-1, vector<vector<int> >(h+2, vector<int>(h+2, -1)));
    repeat(i, w-1) {
        cost += cost2cols(blocks[i], blocks[i+1], h, i);
    }

    return cost;
}

int main() {
    int h = iin();
    int w = iin();

    vector<vector<char> >   blocks(w, vector<char>(h));
    input(blocks, h, w);
    printf("%lld\n", solve(blocks, h, w));
    return 0;
}

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

int iin() {
    int x;
    scanf("%d", &x);
    return  x;
}

llint lin() {
    llint x;
    scanf("%lld", &x);
    return  x;
}

double fin() {
    double  x;
    scanf("%lf", &x);
    return x;
}


Measured memory_bytes: 110208
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.forEach(function(v){
   var arr=v.split(" ").map(Number);
   var a=arr[0];
   var b=arr[1];
   var ans;
   if(35.5>a && 71>b)ans="AAA";
   else if(37.5>a && 77>b)ans="AA";
   else if(40>a && 83>b)ans="A";
   else if(43>a && 89>b)ans="B";
   else if(50>a && 105>b)ans="C";
   else if(55>a && 116>b)ans="D";
   else if(70>a && 148>b)ans="E";
   else ans="NA";
   console.log(ans);
});

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

template <long long Mod>
struct modint {
    ll n;
    modint(ll x = 0) : n((x + Mod) % Mod) {
    }

    modint operator+(const modint &r) const { return modint(*this) += r; }
    modint operator-(const modint &r) const { return modint(*this) -= r; }
    modint operator*(const modint &r) const { return modint(*this) *= r; }
    modint operator/(const modint &r) const { return modint(*this) /= r; }
    modint operator+=(const modint &r) {
        n += r.n;
        n %= Mod;
        return *this;
    }
    modint operator-=(const modint &r) {
        n -= r.n;
        n += Mod;
        n %= Mod;
        return *this;
    }
    modint operator*=(const modint &r) {
        n *= r.n;
        n %= Mod;
        return *this;
    }
    modint operator/=(const modint &r) {
        *this *= modint(r).inv();
        return *this;
    }

    modint operator=(const modint &r) { return n = r.n; }
    modint operator==(const modint &r) const { return n == r.n; }
    modint operator!=(const modint &r) const { return n != r.n; }

    modint inv() const { return pow(Mod - 2); }

    modint pow(const ll x) const {
        if (n == 0) return modint(0);
        if (x == 0) return modint(1);
        if (x == 1) return modint(n);

        modint a = modint(*this);
        a = (a * a).pow(x / 2);

        if (x % 2 == 1) {
            a *= n;
        }
        return a;
    }

    friend ostream &operator<<(ostream &os, const modint &x) { return os << x.n; }
    friend istream &operator>>(istream &is, modint &x) { return is >> x.n; }
};

int main()
{
    using Modint = modint<1000000007>;

    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<int> a(N);
    rep(i,N){
        a[A[i]]++;
    }

    Modint ans = 1;

    if(N%2==0){
        for (int i = 1;i<=N-1;i+=2){
            if(a[i] != 2){
                ans = 0;
                break;
            }
            ans *= 2;
        }
    }else{
        if(a[0] != 1){
            ans = 0;
        }else{
            for(int i=2;i<=N-1;i+=2){
                if(a[i] != 2){
                    ans = 0;
                    break;
                }
                ans *= 2;
            }
        }
    }


    cout << ans << endl;



}


Measured memory_bytes: 4024
#include <iostream>

int main(int argc, char **argv){
	int a = 0;
	int b = 0;

	std::cin >> a >> b;

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

Measured memory_bytes: 3132
#include <iostream>
#include <math.h>
#include <algorithm>
#include <cstring>

using namespace std;

int main() {
    long long n, w;
    cin >> n >> w;
    long long a[n + 1], b[n + 1];
    long long sum_w = 0;
    for (int i = 1; i <= n; i ++) {
        cin >> a[i] >> b[i];
        sum_w += b[i];
    }
    long long dp[n + 1][sum_w + 1];
    memset(dp, 2, sizeof dp);
    for (int i = 1; i < n + 1; i ++) {
        for (int j = 1; j < sum_w + 1; j++) {
            if (j >= b[i]) {
                dp[i][j] = min(dp[i - 1][j], dp[i - 1][j - b[i]] + a[i]);
            }
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if (j == b[i]) dp[i][j] = min(dp[i][j], a[i]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= sum_w; i ++) {
        if (dp[n][i] <= w) ans = i;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 79104
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;
use num::*;


fn main() {
    input! {
        a:String,
    }
    let a=a.chars().collect_vec();
    let v=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    let mut z=[0;26];
    for i in 0..a.len() {
        for j in 0..26 {
            if a[i]==v[j] {z[j]+=1;}
        }
    }
    for i in 0..26 {
        if z[i]%2==1 {println!("No");exit(0)}
    }
    println!("Yes")
}

Measured memory_bytes: 2112
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    int n,k,in,ans=0;
    cin>>n>>k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>in;
        v[in]++;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=0;i<k;i++)
    {
        ans+=(v[i]);
    }
    cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
vector<ll>v;
int main(){
    fastread;
    ll n,i,j,k,l,m;
    cin>>k>>n;
    for(i=1;i<=n;i++){
        cin>>l;
         v.pb(l);
    }
    ll sum=0;
    sort(v.begin(),v.end());
    for(i=0;i<n;i++){
        ll kola=0;
        if(i!=n-1)
            kola=v[i+1]-v[i];
        else
            kola=k-v[n-1]+v[0];
        sum=max(sum,kola);
        ////sum+=(v[i]-v[i-1]);
    }
    cout<<k-sum;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;

int main(void) {
    ll n, i, tmp1, tmp2, ans=0;
    cin >> n;
    ll a[n], b[n], c[n];
    for(i=0; i<n; i++)
        cin >> a[i];
    for(i=0; i<n; i++)
        cin >> b[i];
    for(i=0; i<n; i++)
        cin >> c[i];
    
    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);
    
    for(i=0; i<n; i++) {
        tmp1=lower_bound(a, a+n, b[i])-a;
        tmp2=n-(upper_bound(c, c+n, b[i])-c);
        ans += tmp1*tmp2;
    }
    cout << ans << endl;
}


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

int main() {
	int q;cin>>q;
	multimap<string,int> mp;
	mp.insert(make_pair("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz", 1));
	
	while(q--){
		int query;string key;cin>>query>>key;
		if(query==0){
			int x;cin>>x;
			mp.insert(make_pair(key,x));
		}else if(query==1){
			auto lb = mp.lower_bound(key), ub=mp.upper_bound(key);
			for(auto it=lb;it!=ub;++it) {
				if(it->second == 0) continue;
				cout<<it->second<<endl;
			}
		}else if(query==2){
			mp.erase(key);
		}else{
			string r;cin>>r;
			for(auto it=mp.lower_bound(key);it!=mp.upper_bound(r);++it){
				if((*it).second == 0) continue;
				cout<<((*it).first) << " " << ((*it).second)<<endl;
			}
		}
	}
  return 0;
}



Measured memory_bytes: 24864
#include<stdio.h>

int main(){
  int S[10000];
  int T[500];
  int n,q,i,j,count=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){

      if(S[i]==T[j]){
	count++;
	break;
      }
    }
  }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int>A(N),B(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) cin >> B[i];
    reverse(B.begin(),B.end());
    for(int i = 0; i < N; i++) {
        if(A[i] == B[i]) {
            int now = N,now2 = N;
            for(int j = i+1; j < N; j++){
                if(A[i] != B[j]) now2 = min(now2,j);
                if(A[i] != B[j] && A[i] != A[j]) {now = j;break;}
            }
            int old = now;
            now = -1;
            for(int j = i-1; j >= 0; j--) if(A[i] != B[j] && A[i] != A[j]) {now = j;break;}
            if(!(now+1+N-old < now2-i)) {
                for(int j = i; j < now2; j++){
                    if(j-i < N-old) swap(B[j],B[old+j-i]);
                    else swap(B[j],B[now-(j-i)+(N-old)]);
                }
            }
            else {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 0; i < N; i++) {
        cout << B[i] << ((i+1 == N)?"\n":" ");
    }
}

Measured memory_bytes: 4820
a,b,c,x,y=map(int,input().split())
d=(a+b)/2
import sys
o=x
w=y
count=0
if d>=c:
    if x>=y:
        r=x
        
        x-=y
        
        count+=(y*2*c)
        count+=((r-y)*a)
        print(min(count,o*2*c))
        sys.exit()
      

    else:
        r=y
        
        y-=x
        
        count+=(x*2*c)
  
        count+=((r-x)*b)
        
        
        print(min(count,w*2*c))
        sys.exit()
    
        
else:
    count+=(a*x+b*y)    
    print(count)

    


Measured memory_bytes: 3064
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n,k,s;cin>>n>>k>>s;
	rep(i,0,k) cout<<s<<" ";
	rep(i,k,n) if(s+1<=(ll)1e9) cout<<s+1<<" "; else cout<<1<<" ";
	return 0; 
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 1280
//به نامش
//how we code is who we are :))
#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
const ll MAXN = 2e6 + 10, inf = 1e18, mod = 1e9 + 7;

struct pair_hash {
	template <class T1, class T2>
		std::size_t operator () (const std::pair<T1,T2> &p) const {
			auto h1 = std::hash<T1>{}(p.first);
			auto h2 = std::hash<T2>{}(p.second);

			return h1 ^ h2;  
		}
};

ll pw(ll te, ll tee) {
	if (tee == 0)	return 1;
	ll res = pw(te, tee / 2);
	return (tee % 2 ? te * res * res : res * res);
}

string s;
ll a, b;

void Read_input() {
	cin >> s;
}

void Solve() {
	for (auto i : s)
		if (i == '1')	a++;
		else	b++;
	cout << min(a, b) * 2;
}


int main() {

	ios_base::sync_with_stdio(false);	cin.tie(0);	cout.tie(0);
	//freopen("input.txt", "r", stdin),	freopen("output.txt", "w", stdout);

	Read_input(),	Solve();
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>

using namespace std;

int main()
{
	int A, B, K;
	int i, j;
	int cnt=0;
	cin >> A >> B >> K;

	if (A + K - 1 >= B - K + 1||B-K+1<=0) {
		
		for (int i = A; i <= B; i++) {
		
			cout << i << endl;
			
		}
	}
	else {
		for (int i = A; i <=A+K-1; i++)cout << i << endl;
		for (int i = B-K+1; i <=B; i++)cout << i << endl;
	}

    return 0;
}



Measured memory_bytes: 256
from operator import itemgetter

N = int(input())
job = [list(map(int, input().split())) for i in range(N)]

job = sorted(job, key=itemgetter(0), reverse=True)
job = sorted(job, key=itemgetter(1))

now = 0
des = True
for i, j in enumerate(job):
    j_time = j[0]
    j_dead = j[1]
    now += j_time
    if now > j_dead:
        des = False

if des:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 55280
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
struct Union_Find{
  vi par;
  Union_Find(int N):par(N){
    rep(i,0,N) par[i]=i;
  }
  int root(int X){
    if(par[X]==X) return X;
    return par[X]=root(par[X]);
  }
  void insert(int X,int Y){
    int RX=root(X),RY=root(Y);
    if(RX==RY) return;
    par[RX]=RY;
  }
  bool same(int X,int Y){
    return root(X)==root(Y);
  }
};
signed main(){
  int N,M; cin>>N>>M;
  Union_Find tree(N);
  vii A(M);
  rep(i,0,N){
    int K; cin>>K;
    rep(j,0,K){
      int X; cin>>X;
      A[X-1].pb(i);
    }
  }
  rep(i,0,M){
    if(A[i].size()>0){
      int X=A[i][0];
      rep(j,1,A[i].size()){
        tree.insert(A[i][j],X);
      }
    }
  }
  string ans="YES";
  rep(i,0,N){
    if(!tree.same(i,0)) ans="NO";
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define LOOP(val, times)   for(val = 0; val < (times); val++)
bool bs(vector<int> nn,int n,int j){
  int left=0;
  int right=n;
  while(left<right){
    int mid=(left+right)/2;
    if(nn[mid]==j) return true;
    else if(j<nn[mid]){
      right=mid;
    }
    else if(j>nn[mid]){
      left=mid+1;
    }
  }
  return false;
}

    
int main(){
  int n;
  cin>>n;
  vector<int> nn(n);
  int i;
  LOOP(i,n){
    cin>>nn[i];
  }
  int m;
  cin>>m;
  vector<int> mm(m);
  LOOP(i,m){
    cin>>mm[i];
  }
  int ans=0;
  LOOP(i,m){
    if(bs(nn,n,mm[i])){
      ans++;
    }
  }
  cout<<ans<<endl;
  
}



Measured memory_bytes: 3836
/**
*    created: 24.06.2020 12:52:49
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#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 all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int h, w;
    cin >> h >> w;
    vector<vector<char>> mp;
    rep(i,h) {
        bool ok = false;
        vector<char> tmp(w);
        rep(j,w) {
            cin >> tmp[j];
        }
        rep(j,w) if (tmp[j] == '#') ok = true;
        if (ok) mp.push_back(tmp);
    }
    h = mp.size();
    vector<bool> out(w);
    rep(i,w) {
        bool yes = false;
        rep(j,h) if (mp[j][i] == '#') yes = true;
        if (yes) out[i] = true;
        else out[i] = false;
    }
    rep(i,h) {
        rep(j,w) if (out[j]) cout << mp[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
//	cut here before submit 
//	freopen ("testcase.Differential", "r", stdin );
	double h;
	double minh = 1e100;
	double maxh = 0.0;
	while (~scanf ("%lf", &h ) ){
//		cerr << "h: " << h << endl;
		minh = min (minh, h );
		maxh = max (maxh, h );
	} // end loop
	printf ("%.5f\n", maxh-minh );
		
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h> 

int main(void)
{
	int a,b,c,x,n=0;
	scanf("%d %d %d",&a,&b,&c);
	for(x=a;x<=b;x++)
	{
		if((c%x)==0)
		{
		n++;
		}
	}
	printf("%d\n",n);
	return 0;
}

Measured memory_bytes: 596
package main

import (
	"fmt"
	"math"
)

func abs(n int) int {
	if n < 0 {
		return -n
	}

	return n
}

func solve(N int, ws []int) int {
	sum := 0

	for i := 0; i < len(ws); i++ {
		sum += ws[i]
	}

	min := math.MaxInt64
	leftSum := 0
	for t := 0; t < len(ws)-1; t++ {
		leftSum += ws[t]
		rightSum := sum - leftSum

		if abs(leftSum-rightSum) < min {
			min = abs(leftSum - rightSum)
		}
	}

	return min
}

func main() {
	var N int

	fmt.Scan(&N)

	ws := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&ws[i])
	}

	output := solve(N, ws)

	fmt.Println(output)
}


Measured memory_bytes: 512