akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int r, c, n;
int transform(int x, int y) {
    if (x != 0 && x != r && y != 0 && y != c) return -1;
    if (x == 0) return y;
    if (y == c) {
        return x + c;
    }
    if (x == r) {
        return c - y + c + r;
    }
    if (y == 0) {
        return c + r + c + r - x;
    }
    assert(false);
    return -228;
}
const int maxN = 1e5 + 10;
int delta[2 * maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> r >> c >> n;
    vector < pair < int, int > > all;
    for (int i = 1; i <= n; i++) {
        int x1, y1;
        cin >> x1 >> y1;
        int c1 = transform(x1, y1);
        int x2, y2;
        cin >> x2 >> y2;
        int c2 = transform(x2, y2);
        if (c1 == -1 || c2 == -1) continue;
        if (c1 > c2) swap(c1, c2);
        all.emplace_back(c1, -1);
        all.emplace_back(c2, c1);
    }
    int bal = 0;
    sort(all.begin(), all.end());
    set < int > open;
    for (auto& it : all) {
        if (it.second == -1) open.insert(it.first);
        else {
            open.erase(it.second);
        }
        if (it.second != -1) {
            if (!open.empty() && (*prev(open.end()) >= it.second)) {
                cout << "NO\n";
                return 0;
            }
        }
    }
    cout << "YES\n";
    return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  int ans = 0;
  for(int i = n; i <= m; i++) {
    string s = to_string(i);
    if(s[0] == s[4] && s[1] == s[3]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3756
///I don't wanna read problem's statement anymore
    using namespace std;
    #include<bits/stdc++.h>
    #define ll long long
    #define read freopen("in.txt", "r", stdin)
    #define write freopen("out.txt", "w", stdout)
    #define sf scanf
    #define pb push_back
    #define pfr push_front
    #define reap(i,n) for(int i=0; i<n; i++)
    #define case_ printf("Case %d: ",i)
    #define check printf("working\n")
    #define pf printf
    #define ato(v) for(auto k:v)
    #define vi vector<int>
    #define vll vector<ll>
    #define vec_ch vector<char>
    #define list_i list<int>
    #define list_ll list<ll>
    #define list_ch list<ch>
    #define M 100005
    #define ios ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);


    ll d[M];
    ll a[M];
    int main(){
        ios
        //if(read)
        //read;
        //write;
        //double st = clock();

        int n,k;
        cin>>n>>k;
        for(ll i=0; i<n; i++) cin>>a[i];

        for(ll i=1; i<n; i++){
            d[i]=d[i-1]+abs(a[i]-a[i-1]);
            for(int j=1; j<=k; j++){
                if(i+1>j)
                    d[i]=min(d[i], d[i-j]+abs(a[i]-a[i-j]));
            }
               // cout<<d[i]<<"akshd";
           // cout<<d[i]<<" "<<i<<endl;
        }
        cout<<d[n-1]<<endl;
        //double en = clock();
        //cerr<<"Exicution Time: "<<((en-st)/CLOCKS_PER_SEC*1000)<<endl;
        return 0;
    }


Measured memory_bytes: 1792
#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 count=0;
  
  for (int i=100; i>0; i--){
    for (int j=0; j<N; j++){
      if (vec.at(j) == i){
        count++;
        break;
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var n, m, x int
        fmt.Scan(&n, &m, &x)

        var lcost, rcost int
        for i := 0; i < m; i++ {
                var a int
                fmt.Scan(&a)
                if a < x {
                        lcost++
                        continue
                }
                rcost++
        }

        if lcost < rcost {
                fmt.Println(lcost)
                return
        }
        fmt.Println(rcost)
}

Measured memory_bytes: 512
s=list(input())
t=list(input())
if s==t:
  print("Yes")
  exit()
l=len(s)  
a=s.copy()
for i in range(l):
  a.append(a[0])
  del a[0]
  if a==t:
    print("Yes")
    exit()
print("No")

Measured memory_bytes: 3060
n = gets.to_i
ary = gets.chomp.split("")

left_black = 0
right_white = ary.count('.')
sary = [[left_black, right_white]]
n.times do |i|
  if ary[i] == '#'
    left_black += 1
  else
    right_white -= 1
  end
  sary << [left_black, right_white]
end

puts sary.map{|a| a[0] + a[1] }.min

Measured memory_bytes: 29820
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		    int a = scanner.nextInt();
		    if( a < 1200) 
		    {
		    	System.out.println("ABC");
		    }
		    else 
		    {
		    	System.out.println("ARC");
		    }
		    
		    scanner.close(); }
		  }

Measured memory_bytes: 22996
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, A: "List[int]"):
    # if N % (K - 1) in (0, 1):
    #     print(N // (K-1))
    #     return
    print((N-1) // (K-1) + (1 if (N-1) % (K-1) else 0))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
#include <iostream>
#include <vector>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  int count=0;
  for(int j=0;j<1000000;j++){
    for(int k=0;k<N;k++){
      if(A.at(k)%2!=0){
        goto AB;}
        A.at(k)=A.at(k)/2;
    }
    count++;
  }
  AB:
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define pi 3.1415926536
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define INF 2147483647
#define _INF -2147483647
#define MM multimap
#define PB push_back
#define MAXN 100004
using namespace std;
typedef long long ll;

int main() {
    int S;
    cin >> S;
    int first = S / 100;
    int second = S % 100;
    int cnt = 0;
    string ans;
    if (second != 0 && second <= 12) {
        ans = "YYMM";
        cnt++;
    }
    if (first != 0 && first <= 12) {
        ans = "MMYY";
        cnt++;
    }
    if (cnt == 2) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    } else if (cnt == 0) {
        cout << "NA" << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int total = 0;
        int price;
        int mx = -1;
        for (int i = 0; i < n; i++) {
            price = sc.nextInt();
            if (mx < price) {
                mx = price;
            }
            total += price;
        }
        total -= (mx >> 1);
        System.out.println(total);
        sc.close();
    }
}


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

vector<int> d;

bool check(int i){
    bool ok = true;
    while(i){
        if(binary_search(ALL(d),i%10)) ok = false;
        i /= 10;
    }
    return ok;
}

int main(){
    int n,k; cin >> n >> k;
    rep(i,k) {
        int x; cin >> x;
        d.push_back(x);
    }
    while(1){
        if(check(n)) {
            cout << n << endl;
            return 0;
        }
        n++;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
#include <unordered_map>
#include <cmath>
#include <iomanip>

using namespace std;


int main() {
    long long N,K;
    cin >> N >> K;
    vector<long long> H(N);
    long long answer = 0;
    for(long long i=0; i<N; i++){
        cin >> H[i];
    }

    sort(H.rbegin(), H.rend());

    for(long long i=0; i<N; i++){
        if(i<K) {
            continue;
        }else {
            answer += H[i];
        }
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 1792
// =====================================================================
// macros
// =====================================================================

/// input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        let mut s = {
            use std::io::Read;
            #[allow(unused_mut)]
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        #[allow(unused_mut)]
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/// yet another input macro from https://qiita.com/hatoo@github/items/fa14ad36a1b568d14f3e
#[allow(unused_macros)]
macro_rules! inputln {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

// =====================================================================
// functions
// =====================================================================

fn main() {
    input!{
        n: usize,
    }
    if n % 2 == 0{
        println!("{}",(n/2).to_string());
    }else{
        println!("{}",(n/2+1).to_string());
    }
}


Measured memory_bytes: 4352
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <istream>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll = vector<ll>;
class Solution {
public:
    void solve(std::istream& in, std::ostream& out) {
        ll n;
        in >> n;
        vll a(n);
        for (int i = 0; i < n; i++) {
            in >> a[i];
        }
        sort(all(a));
        reverse(all(a));
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            ans += a[i] * (i % 2 == 0 ? 1 : -1);
        }
        out << ans << endl;
    }
};
void solve(std::istream& in, std::ostream& out) {
    out << std::setprecision(12);
    Solution solution;
    solution.solve(in, out);
}
#include <fstream>
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream& in = cin;
    ostream& out = cout;
    solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] number = line.split(" ");
        int n = Integer.parseInt(number[0]);
        int m = Integer.parseInt(number[1]);
        int[] a = new int[n];
        int k = 0;
        int l = 0;
        for(int i = 0; i < m; i++) {
            line = br.readLine();
            k = Integer.parseInt(line.split(" ")[0]);
            l = Integer.parseInt(line.split(" ")[1]);
            a[k - 1]++;
            a[l - 1]++;
        }
        for(int i = 0; i < n; i++) {
            System.out.println(a[i]);
        }
    }
}

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

using namespace std;

const int MOD=1000000007;
int N;
int A[4001][4001];
int B[4001][4001];
int C[4001][4001];
int ch[8001][4001];

void addmod(int& x, int v)
{
    x+=v;
    if(x>=MOD)
        x-=MOD;
}

int main()
{
    for(int i=0; i<=8000; i++)
    {
        ch[i][0]=1;
        for(int j=1; j<=min(i, 4000); j++)
        {
            ch[i][j]=ch[i-1][j];
            addmod(ch[i][j], ch[i-1][j-1]);
        }
    }
    scanf("%d", &N);
    int ans=0;
    int a, b;
    for(int i=0; i<N; i++)
    {
        scanf("%d%d", &a, &b);
        A[2000-a][2000-b]++;
        B[2000+a][2000+b]++;
        ans=(ans-ch[2*(a+b)][2*a]+MOD)%MOD;
    }
    for(int i=0; i<=4000; i++) for(int j=0; j<=4000; j++)
    {
        if(i>0)
        {
            addmod(C[i][j], C[i-1][j]);
            addmod(C[i][j], A[i-1][j]);
        }
        if(j>0)
        {
            addmod(C[i][j], C[i][j-1]);
            addmod(C[i][j], A[i][j-1]);
        }
        if(B[i][j])
            ans=(ans+1LL*B[i][j]*C[i][j])%MOD;
    }
    ans=1LL*ans*((MOD+1)/2)%MOD;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 217216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

inline void solve(){

  string s, t;
  cin >> s>> t;
  s+=s;
  if(s.find(t)!=string::npos)
    cout <<"Yes\n";
  else
    cout <<"No\n";



}


struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;
signed main(){solve();return 0;}


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

using namespace std;

typedef long long int64;
typedef vector<int,int> vec;
#define read(a) scanf("%d",&a)
#define printarr(a,n) for(int i=0;i<n;i++) cout<<a[i]<<" ";

const int rmax = 1e5 + 10;
const int inf = INT_MAX;

int fx[] = {0, 0, 1, -1};
int fy[] = {1, -1, 0, 0};

int main()
{

    string grid[55];
    int h,w,x,y;
    cin>>h>>w;

    for(int i=0; i<h; i++)
        cin>>grid[i];

    bool flag = true;
    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {


            if(grid[i][j] == '#')
            {
                bool test = false;
                for(int k = 0; k<4; k++)
                {
                    x = i + fx[k];
                    y = j + fy[k];

                    if(x < 0 or y < 0 or x >= h or y >=w)
                        continue;
                    if(grid[x][y] == '#')
                        test = true;
                }

                if(test == false)
                    flag = false;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 256
// AtCoder.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

//#include "pch.h"

#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;

int main() 
{
	int n;
	vector<queue<int>> vals;

	cin >> n;
	vals.resize(n);

	int k;

	for (int i = 0; i<n; ++i)
	{
		for (int j = 0; j < n - 1; ++j)
		{
			cin >> k;
			vals[i].push(k-1);
		}
	}

	int days = 1;
	int matches = 0;
	const int totalMatches = (n)*(n - 1) / 2;

	vector<int> matchBits;
	matchBits.resize(n, 0);

	bool isDone = false;
	bool isFail = false;

	vector<int> hadMatch;
	hadMatch.resize(n);
	for (int i = 0; i < n; ++i)
	{
		hadMatch[i] = i;
	}
	int nHadMatch = n;

	vector<int> hadMatch2;
	hadMatch2.resize(n);

	while (true)
	{
		bool matchFound = false;
		int nHadMatch2 = 0;

		for(int k=0; k<nHadMatch; ++k)
		{ 
			int i = hadMatch[k];

			if (matchBits[i])
			{
				continue;
			}

			if (vals[i].empty())
			{
				continue;
			}

			int opp = vals[i].front();

			if (matchBits[opp])
			{
				continue;
			}

			if (vals[opp].empty())
			{
				isFail = true;
				break;
			}

			if (vals[opp].front() == i)
			{
				vals[opp].pop();
				vals[i].pop();
				matchBits[opp] = 1;
				matchBits[i] = 1;
				matchFound = true;
				++matches;
				hadMatch2[nHadMatch2++] = i;
				hadMatch2[nHadMatch2++] = opp;
			}

			if (matches == totalMatches)
			{
				cout << days << endl;
				isDone = true;
				break;
			}
		}

		if (matchFound == false || isFail)
		{
			cout << "-1" << endl;
			break;
		}

		if (isDone)
		{
			break;
		}

		++days;
		nHadMatch = nHadMatch2;
		for (int i = 0; i < nHadMatch2; ++i)
		{
			hadMatch[i] = hadMatch2[i];
		}
		memset(&matchBits[0], 0, sizeof(int)*matchBits.size());
	}

	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
const int maxn = 1e5 + 10;

int main()
{
    ll ans = 0;
    ll x;
    cin >> x;
    ans += x / 500 * 1000;
    x %= 500;
    ans += x / 5*5;
    cout<<ans<<endl;
    return 0;
}


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

int main(void) {
	int n, a, cnt = 0;
	
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a;
		while (a % 2 == 0)
			cnt++, a /= 2;
	}
	
	cout << cnt << endl;
	
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};


class Math
{
public:
    vector<ll>fact,invfact;
    Math( int n )
    {
        fact.resize(n);
        invfact.resize(n);
        fact[0] = invfact[0] = 1;
        for(int i=1;i<n;i++)
        {
            fact[i] = mod( i * fact[i-1] );
            invfact[i] = modinv( fact[i] );
        }
    }
    ll modinv( ll x, ll m = MOD )
    {
        return expo(x,m-2,m);
    }
    ll expo( ll base, ll exp, ll m = MOD )
    {
        ll res = 1;
        while( exp )
        {
            if( exp&1 )
                res = mod( res*base, m );
            base = mod( base*base, m );
            exp >>= 1;
        }
        return res;
    }
    ll choose( ll n, ll k )
    {
        if( k < 0 || k > n ) return 0;
        ll ans = fact[n];
        ans = mod( ans * invfact[n-k] );
        ans = mod( ans * invfact[k] );
        return ans;
    }
};


int main() 
{
    fastio();

    Math m(MAXN);

    ll n,a,b;
    cin>>n>>a>>b;

    ll ca = 1, cb = 1;
    for(int i=0;i<a;i++)
    {
        ca = mod( ca * mod(n-i) );
        ca = mod( ca * m.modinv(i+1) );
    }
    for(int i=0;i<b;i++)
    {
        cb = mod( cb * mod(n-i) );
        cb = mod( cb * m.modinv(i+1) );
    }

    ll ans = m.expo(2,n) - ca - cb - 1;
    ans = mod( ans );
    cout<<ans,nl;

    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


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

int main(void){
  string source;
  cin >> source;
  int score = 0;
  for(int i = 0; i < source.size(); i++){
    if(source[i] == 'p')score--;
  }
  score += source.size()/2;
  cout << score << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rept(i,k,n) for(int i = (k); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> seen(n);
    cout<<1<<" "<<2<<endl;
    int a = 3,b = n;
    rep(i,(m-1)/2){
        cout<<a<<" "<<b<<endl;
        a++;b--;
    }
    if((b-a)%2) b--;
    rep(i,m/2){
        cout<<a<<" "<<b<<endl;
        a++;b--;
    }
    return 0;
}

Measured memory_bytes: 3960
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String n = sc.next();
        int sum = 0;
        while(!(n.equals("0"))){
            for(int i=0;i<n.length();i++){
                sum += Character.getNumericValue(n.charAt(i));
            }
            System.out.println(sum);
            n = sc.next();
            sum = 0;
        }
    }
}


Measured memory_bytes: 26384
<?php
  fscanf(STDIN, "%d %d %d",$a,$b,$c);
  
  if(($a+$b+$c === 17) && ($a === 5 ||7) && ($b === 5 ||7) && ($c === 5 ||7) ){
    echo 'YES';
  }else {
   echo 'NO'; 
  }

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

int main() {
  int n;
  cin >> n;
  if (n % 2 == 0){
    cout << 0.500000000 << endl;
  }
  else{
    double m = n/2 + 1;
    cout << fixed << setprecision(10);
    cout << m/n << endl;
  }
}

Measured memory_bytes: 3788
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}


int main() {
    string n;
    cin >> n;
    ll ans = 0;
    ll zans = 0;
    for (int i = 0; i < n.size(); i++) {
        if (n.at(i) == '0')ans++;
        else zans++;
    }
    cout << min(ans,zans)*2 << endl;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int y = saori.saori_hayami();
		if((x+y) % 3 == 0 || x % 3 == 0 || y % 3 == 0){
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const int INF = 1e9;

int main() {
  ll n, k;
  ld ans = 0, cnt = 0;
  cin >> n >> k;
  vector<ll> p(n);
  vector<ld> e(n);
  rep(i, n) cin >> p[i], e[i] = (1 + p[i]) / 2.0;
  rep(i, k) cnt += e[i];
  ans = max(ans, cnt);
  for (int i = 1; i <= n - k; ++i) {
    cnt += e[i + k - 1] - e[i - 1];
    ans = max(ans, cnt);
  }

  printf("%.10Lf", ans);
  return 0;
}


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

int main() {
	int n, on, tw, th;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	on = 0;
	tw = 0;
	th = 0;
	for (int i = 0; i < n; ++i)
	{
		if (a[i]==1) on++;
		else if (a[i]==2) tw++;
		else th++;
	}

	vector<vector<vector<double> > > dp(n+1, vector<vector<double> >(n+1, vector<double>(n+1, 0.0)));

	for (int l = 1; l < n+1; ++l)
	{
			for (int k = 0; k < th+1; ++k)
			{
				for (int j = 0; j < l-k+1; ++j)
				{
					int i = l-k-j;
					if (i>0) dp[i][j][k] += dp[i-1][j][k]*(double)i;
					if (i<n&&j>0) dp[i][j][k] += dp[i+1][j-1][k]*(double)j;
					if (j<n&&k>0) dp[i][j][k] += dp[i][j+1][k-1]*(double)k;
					dp[i][j][k] += (double)n;
					dp[i][j][k] /= (double)l;
				}
			}
	}

	cout << setprecision(12) << dp[on][tw][th] << endl;
	return 0;
}

Measured memory_bytes: 216960
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main(void){
    int N,M,S;
    long ans=0;
    cin>>N;
    VVI s(N);
    VI L(N);
    priority_queue<int> que;
    rep(i,N){
        cin>>L[i];
        rep(j,L[i]){
            cin>>S;
            //cout<<S<<endl;
            s[i].push_back(S);
        }
    }
    //cout<<s[1][0]<<endl;
    for(int i=N-1;i>=0;i--){
        rep(j,L[i]){
            que.push(s[i][j]);
        }
        ans+=que.top();
        que.pop();
    }
    cout<<ans<<endl;
}




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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


int N, M;
vector<vec> G;
int dp[100005];

int rec(int n){
    if(dp[n] >= 0) return dp[n];

    int res=0;
    for(auto nv: G[n]){
        res = max(res, rec(nv)+1);
    }

    return dp[n] = res;
}

void solve() {
    cin >> N >> M;
    G.resize(N);
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
    }

    memset(dp, -1, sizeof(dp));

    int ans=0;
    rep(i, N) ans = max(ans, rec(i));

    cout << ans << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

int a[301][301];
pair<int,int> q[301 * 301];
int mp[301 * 301];

signed main(){

  int H,W,D; cin >> H >> W >> D;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      int p; cin >> p;
      q[p] = {i,j};
    }
  }

  for(int i = 1; i < H*W+1; i++){
    if(i <= D){
      mp[i] = 0;
    }
    else {
      int nx = q[i].first;
      int ny = q[i].second;
      int px = q[i-D].first;
      int py = q[i-D].second;
      mp[i] = mp[i-D] + abs(nx-px) + abs(ny-py);
    }
  }

  int Q; cin >> Q;
  for(int i = 0; i < Q; i++){
    int L,R; cin >> L >> R;
    cout << mp[R]-mp[L] << endl;
  }

  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define LL long long

const int oo = 0x3f3f3f3f;
const int H = 10 + 5;
const int W = 1e3 + 5;

int h, w, k, ans = oo;
char s[H][W];
int state, pre[H][W], cut[W];

int main() {
    scanf("%d %d %d", &h, &w, &k);
    for(int i = 1; i <= h; ++i) scanf("%s", s[i] + 1);
    for(int i = 1; i <= h; ++i)
        for(int j = 1; j <= w; ++j)
            pre[i][j] = pre[i][j - 1] + (s[i][j] - '0');
    for(int state = 0; state < 1 << h - 1; ++state) {
        // pos[i] = state & (1 << i - 1)
        int finish = 1, last = 0, now = 0, cur = 0;
        for(int j = 1; j <= w; ++j) { // 第 j 列右边切
            for(int i = 1; i <= h; ++i) {
                now += pre[i][j] - pre[i][last];
                if(i == h || state & (1 << i - 1)) { // 第 i 行下面切
                    if(now > k) cut[j - 1] = 1, last = j - 1;
                    now = 0;
                }
            }
        }
        last = now = 0;
        for(int j = 1; j <= w; ++j) if(cut[j]) {
            for(int i = 1; i <= h; ++i) {
                now += pre[i][j] - pre[i][last];
                if(i == h || state & (1 << i - 1)) { // 第 i 行下面切
                    if(now > k) finish = 0;
                    now = 0;
                }
            }
            last = j;
        }
        for(int i = 1; i <= w - 1; ++i) if(cut[i]) cur++, cut[i] = 0;
        if(finish)
          ans = std::min(ans, __builtin_popcountl(state) + cur);
    }
    printf("%d", ans);
    return 0;
}
/*
4 10 4
1110010010
1000101110
0011101001
1101000111

*/


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

int main(){
    ll a, b, c; cin >> a >> b >> c;
    ll p = c;
    c--;
    c -= b;
    c -= a;
    c = max(c, 0LL);
    cout << b + abs(c-p) << endl;
}

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

sys.setrecursionlimit(101010)

def dfs(v, adj_list, depth, visited):
    visited[v] = True
    x = depth
    for w in adj_list[v]:
        if not visited[w]:
            x += dfs(w, adj_list, depth + 1, visited)

    return x


def solve(n, d):

    if n < 7:
        print(-1)
        return

    d.sort()
    w = [1] * n
    edges = []
    adj_list = [[] for _ in range(n)]
    for j in range(n - 1, 0, -1):
        di, i = d[j]
        pdi = di - n + 2 * w[i]
        p = None
        lo, hi = 0, j
        while lo < hi:
            mid = (lo + hi) // 2
            xdi, xi = d[mid]
            if xdi == pdi:
                p = xi
                break
            elif xdi < pdi:
                lo = mid + 1
            else:
                hi = mid
        if p is None:
            print(-1)
            return
        u, v = i, p
        if v < u:
            u, v = v, u
        edges.append((u + 1, v + 1))
        adj_list[u].append(v)
        adj_list[v].append(u)
        w[p] += w[i]

    d0, r = d[0]
    visited = [False] * n
    x = dfs(r, adj_list, 0, visited)
    if x != d0:
        print(-1)
        return

    edges.sort()
    for uv in edges:
        u, v = uv
        print('{} {}'.format(u, v))



def main():
    n = input()
    n = int(n)
    d = []
    for i in range(n):
        di = input()
        di = int(di)
        d.append((di, i))


    solve(n, d)


if __name__ == '__main__':
    main()



Measured memory_bytes: 95688
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int a,b,c;
    cin>>a>>b>>c;
    int x=min(a,b),y=max(a,b);
    if(x<c&&c<y) Yes;
    else No;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
///////////////////////////////////////////////
int main(){
	int index = 1;
	int s;
	SCD(s);
	set<int> S;
	S.insert(s);
	vector<int> a;
	a.PB(s);

	FORq(i,1,1000001){
		if (a[i-1] % 2 == 0){
			a.PB(a[i-1] / 2);
		}else{
			a.PB(3 * a[i-1] + 1);
		}
		
		if (SIN(a[i],S)){
			PRINTD(i+1);
			return 0;
		}
		S.insert(a[i]);
	}
}

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

int main() {
  int a,b,c,d,num;
  cin >> a>>b>>c;
  num=0;
  for(int i=1;i<a+1;i++){
  	d=i%10+(i%100)/10+(i%1000)/100+(i%10000)/1000+i/10000;
    if(b<=d&&d<=c){
    	num+=i;
    }
  }
  cout <<num <<endl;
 }

Measured memory_bytes: 256
#pragma warning disable
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using System.Collections;
using static System.Math;
using static System.Console;

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var ts = G();
		var T = ts[1];
		ts = G();
		var s = 0L;
		var last = -T - 1;
		foreach (var t in ts)
		{
			if (last + T <= t) s += T;
			else s += t - last;
			last = t;
		}
		WriteLine(s);
	}
	long GCD(long a, long b)
	{
		var n = (ulong)Abs(a); var m = (ulong)Abs(b);
		if (n == 0) return (long)m; if (m == 0) return (long)n;
		int zm = 0, zn = 0;
		while ((n & 1) == 0) { n >>= 1; zn++; }
		while ((m & 1) == 0) { m >>= 1; zm++; }
		while (m != n)
		{
			if (m > n) { m -= n; while ((m & 1) == 0) m >>= 1; }
			else { n -= m; while ((n & 1) == 0) n >>= 1; }
		}
		return (long)n << Min(zm, zn);
	}
}

Measured memory_bytes: 26720
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include <queue>
using namespace std;
long long int ans1, ans2, sum1, sum2;
int n, i;
long long int a[100005];
int main()
{
    cin >> n;
    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    if (a[1] >0)
    {
        sum1 = a[1];
        ans2= a[1] + 1;
        sum2 = -1;
    }
    else if (a[1] == 0)
    {
        sum1 = 1;
        ans1 = ans2 = 1;
        sum2 = -1;
    }
    else
    {
        sum1 = 1;
        ans1 = abs(a[1]) + 1;
        sum2 = a[1];
    }
    for (i = 2; i <= n; i++)
    {
        if (sum1 > 0)
        {
            if (a[i] + sum1 >= 0)
            {
                ans1 += a[i] + sum1 + 1;
                sum1 = -1;
            }
            else
            {
                sum1 += a[i];
            }
        }
        else
        {
            if (a[i] + sum1 <= 0)
            {
                ans1 += abs(sum1 + a[i]) + 1;
                sum1 = 1;
            }
            else
            {
                sum1 += a[i];
            }
        }
    }
    if (sum1 == 0)
    {
        ans1++;
    }
    for (i = 2; i <= n; i++)
    {
        if (sum2 > 0)
        {
            if (a[i] + sum2 >= 0)
            {
                ans2 += a[i] + sum2 + 1;
                sum2 = -1;
            }
            else
            {
                sum2 += a[i];
            }
        }
        else
        {
            if (a[i] + sum2 <= 0)
            {
                ans2 += abs(sum2 + a[i]) + 1;
                sum2 = 1;
            }
            else
                sum2 += a[i];
        }
    }
    if (sum2 == 0)
    {
        ans2++;
    }
    cout << min(ans1, ans2)<< endl;
//  cin>>ans1;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
}

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

using db = double;
const db eps = 1e-9;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	bool operator <(poi p) const {
		return tie(x, y) < tie(p.x, p.y);
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
	db len() {
		return sqrt(x * x + y * y);
	}
};
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}

using vp = vector <poi>;
vp convex(vp v) {
	sort(v.begin(), v.end()); vp r;
	for(int i = 0; i < v.size(); i ++) {
		while(r.size() > 1 &&
			sgn(xmul(*++r.rbegin(), v[i], *r.rbegin())) >= 0)
			r.pop_back();
		r.push_back(v[i]);
	}
	int d = r.size();
	for(int i = (int)v.size() - 2; i >= 0; i --) {
		while(r.size() > d &&
			sgn(xmul(*++r.rbegin(), v[i], *r.rbegin())) >= 0)
			r.pop_back();
		if(i != 0) r.push_back(v[i]);
	}
	return r;
}

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(false);
	int n; cin >> n; vp v;
	for(int i = 0; i < n; i ++) {
		db x, y; cin >> x >> y;
		v.push_back({x, y});
	}
	v = convex(v);

	n = v.size();
	/*
	for(int i = 0; i < n; i ++)
		cout << v[i].x << ' ' << v[i].y << '\n';
		*/
	{
		db ans = 0;
		auto upd = [&](int i, int j) {
			db t = (v[i] - v[j]).len();
			if(t > ans) ans = t;
		};
		int j = 1 % n;
		for(int i = 0; i < n; i ++) {
			while(sgn(xmul(v[i], v[(i + 1) % n], v[j]),
				xmul(v[i], v[(i + 1) % n], v[(j + 1) % n])) < 0)
				j = (j + 1) % n;
			//cout << i << ' ' << j << '\n';
			upd(i, j); /*upd((i + 1) % n, j);*/
			/*upd(i, (j + 1) % n);*/ /*upd((i + 1) % n, (j + 1) % n);*/
		}
		cout << ans << '\n';
	}

	return 0;
}

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

int n;
bitset<5000000>f;

int main(){
	cin>>n;int j,k;
	f[0]=1;
	while(n--){
		cin>>j;
		f|=f<<j;
		k+=j;
	}
	int i;
	for(i=(k+1)/2;!f[i];i++);
	cout<<i;
	return 0;
}

Measured memory_bytes: 2176