akhauriyash/Code-Regression huggingface dataset:
macro_rules! get {
    (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) => {
        {
            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<_>>()
    };
}

fn main() {
    let N = get!(String);

    let ans = N.chars().fold(
        0,
        |acc, c| {
            if c == '2' {
                acc + 1
            } else {
                acc
            }
        }
    );

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template<typename T> inline bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> inline bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// variable -------------------------------------------

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 1000000007ll;

// structure ------------------------------------------

// function -------------------------------------------

// main -----------------------------------------------

int main() {
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    ll sum_min = 0, sum_max = 0;
    PREP(i, k, n+2){
        sum_min = i * (i-1) / 2;
        sum_max = n * i - sum_min;
        ans += (sum_max - sum_min + 1) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    int n, i;
    cin >> n >> i;

    cout << n-i+1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<bool> check(N);
    vei a(N); 
    rep(i,N) {
        cin >> a[i];
        a[i]--;
        check[i] = false;
    }
    check[0] = true;

    int i = 0;
    int cnt = 1;
    while(cnt < N) {
        if(check[ a[i] ] == true){
            cout << -1 << endl;
            return 0;
        }
        else {
            if(a[i] == 1){
                cout << cnt << endl;
                return 0;
            }
            check[ a[i] ] = true;
            i = a[i];
            cnt++;
        }
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define rep(i,a,b) for (int i = a; i < b; i++)
#define repn(i,a,b) for (int i = a; i >=b ;i--)
#define MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
  int h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;  
  int tmp = (h2-h1)*60 + m2-m1;
  cout<<tmp-k;
 
return 0;
}

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

int main () {
  int m, f, r;

  while (cin >> m >> f >> r) {
    if (m == -1 && f == -1 && r == -1){
      break;
    }
    if (m == -1 || f == -1) {
      cout << "F" << endl;
    } else if (80 <= m + f) {
      cout << "A" << endl;
    } else if (65 <= m + f && 80 > m + f) {
      cout << "B" << endl;
    } else if (50 <= m + f && 65 > m + f) {
      cout << "C" << endl;
    } else if (30 <= m + f && 50 > m + f) {
      if (50 <= r) {
        cout << "C" << endl;
      } else {
        cout << "D" << endl;
      }
    } else if (30 > m + f) {
      cout << "F" << endl;
    }

  }
  return 0;

}

Measured memory_bytes: 1156
while n = gets.chomp.to_i
  break if n == 0

  salers = Hash.new(0)

  n.times do
    i, p, q = gets.chomp.split.map(&:to_i)
    salers[i] += p * q
  end

  million_salers = salers.select { |key, value| value >= 1_000_000 }
  if million_salers.any?
    million_salers.each do |key, value|
      puts key
    end
  else
    puts 'NA'
  end

end

Measured memory_bytes: 8812
#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

namespace atcoder {
namespace {
bool check() {
  string line;
  cin >> line;
  assert(line.size() == 4);
  sort(line.begin(), line.end());
  return line[0] == line[1] && line[2] == line[3] && line[1] != line[2];
}
} // namespace
} // namespace atcoder

int main() {
  using namespace atcoder;
  cout << (check() ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define all(a) a.begin(),a.end()
#define setDP(arr) memset(arr,-1,sizeof arr)
#define Clear(arr) memset(arr,0,sizeof arr)
#define li(x) x.size()-1
#define oo 2000000000
#define inf 1000000000000000000
#define M 1000000007
#define M2 1000000009
#define pii pair<int,int>
typedef long long ll;
using namespace std;
const int N = 2e5+10;
const int SQRTN = 320;
const int LOGN = 20;
const double PI = acos(-1);

int a[N],n,dp[N];

int main() {
    cin >> n;
    for(int i = 0 ;i < n ; i++){
        scanf("%d",&a[i]);
        dp[a[i]]=1;
        if(dp[a[i]-1])dp[a[i]]=1+dp[a[i]-1];
    }
    int x = 0;
    for(int i = 0 ; i < n ; i++){
        x=max(x,dp[i+1]);
    }
    cout << n-x << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  vector<char> s(4);
  int i;
  for(i=0;i<4;i++) cin >> s[i];
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3]) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;


int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);
    
    int n, m;
    scanf("%d %d", &n, &m);
    vector<int> goal(n+1, -1);
    vector<queue<int>> neighbor(n+1);

    int a, b;
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &a, &b);
        neighbor[a].push(b);
        neighbor[b].push(a);
    }

    queue<int> q;
    q.push(1);
    int dis = 0;
    while (!q.empty()){
        int room = q.front();
        q.pop();
        queue<int> nq = neighbor[room];
        while (!nq.empty()){
            int next = nq.front();
            nq.pop();
            if (goal[next] == -1) {
                goal[next] = room;
                q.push(next);
            }
        }
    } 

    printf("Yes\n");
    for(int i = 2; i <= n; i++) {
        printf("%d\n", goal[i]);
    }
}

Measured memory_bytes: 413432
using System;

public class AtCoder{
	public static void Main(){
		string[] s;
		s = Console.ReadLine().Trim().Split(' ');
		int n, x;
		n = int.Parse(s[0]);
		x = int.Parse(s[1]);
		
		s = Console.ReadLine().Trim().Split(' ');
		int[] a = new int[n];
		for (int i=0; i<n; i++){
			a[i] = int.Parse(s[i]);
		}
		Array.Sort(a);
		
		bool f = true;
		int y = 0;
		int c = 0;
		while(f){
			y = y + a[c];
			if (y>x){
				f = false;
				Console.WriteLine(c);
			}
			if (y==x){
				f = false;
				Console.WriteLine(c+1);
			}
			c++;
			if(f){
			if (c==n){
				f = false;
				Console.WriteLine(c-1);
			}
			}
		}
	}
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

struct BIT{
	int N;
	vector<int>bit;
	void add(int x,int y){
		while(x<=N){
			bit[x]+=y;x+=x&-x;
		}
	}
	int sum(int x){
		int res=0;
		while(x>0){
			res+=bit[x];x-=x&-x;
		}
		return res;
	}
	BIT(int x):N(x),bit(x+1){}
};

int N,Q;
int A[500005];
pair<P,int>q[500005];
int las[500005];
int ans[500005];
signed main(){
	cin>>N>>Q;
	rep(i,N)cin>>A[i];
	rep(i,Q){
		cin>>q[i].first.second>>q[i].first.first;
		q[i].first.second--;q[i].first.first--;
		q[i].second=i;
	}
	int idx=0;
	sort(q,q+Q);
	BIT bit(N+10);
	fill(las,las+N+1,-1);
	rep(i,N){
		if(las[A[i]]!=-1){
			bit.add(las[A[i]]+1,-1);
		}
		las[A[i]]=i;
		bit.add(i+1,1);
		while(idx<Q&&q[idx].first.first<=i){
			ans[q[idx].second]=bit.sum(q[idx].first.first+1)-bit.sum(q[idx].first.second);
			idx++;
		}
	}
	rep(i,Q)cout<<ans[i]<<"\n";
}


Measured memory_bytes: 31092
#include <iostream>
using namespace std;
int data[220],N;
unsigned long long dp[220][21];
int main(){
	cin>>N;
	for(int i=1;i<=N;i++){
		cin>>data[i];
	}
	dp[0][0]=1;
	for(int i=0;i<=N;i++){
		for(int j=0;j<21;j++){
		if(dp[i][j]>0){
			if(j+data[i+1]<21){
				dp[i+1][j+data[i+1]]+=dp[i][j];
			}
			if(i!=0 && j-data[i+1]>=0){
				dp[i+1][j-data[i+1]]+=dp[i][j];
			}
		}
		}
	}
	cout<<dp[N-1][data[N]]<<endl;
	return 0;
}
	

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

struct data_t {
	int height;
	int width;
	int dia;

	bool operator<( const data_t& right) const {
		if (dia == right.dia) {
			return (height < right.height);
		}
		else {
			return ((dia == right.dia) || (dia < right.dia));
		}
	}
};

int main(void) {
	int h,w;
	int ind = 0;
	cin >> h;
	cin >> w;
	int lim = ((149-1)*149)/2;
	std::vector<data_t> all(lim);

	for (int i = 1; i < 150; i++) {
		for (int j = i+1; j < 151; j++) {
			all[ind].height = i;
			all[ind].width = j;
			all[ind].dia = pow(i,2) + pow(j,2);
			ind++;
		}
	}

	std::sort(all.begin(), all.end());

	while (h!=0||w!=0) {
		int d = pow(h,2) + pow(w,2);
		bool find = false;
		bool pro = false;
		for (int i = 0; i < lim && !find; i++) {
			if (all[i].dia > d) {
				cout << all[i].height << " " << all[i].width << endl;
				find = true;
			}
			if (all[i].dia == d) {
				if (pro) {
					cout << all[i].height << " " << all[i].width << endl;
					find = true;
				}
				else if (all[i].height == h) {
					pro = true;
				}
			}
		}
		cin >> h;
		cin >> w;
	}

	return 0;
}

Measured memory_bytes: 3140
<?php
//(map座標全てに0を入れる) $map[$c][$y][$x]として、ブロックがある座標を１に。
//スタート地点上にあるブロックの「色」を調べる。なければNG。その色のブロックの座標のみたどる。
//スタート地点から深さ優先探索でmove。ゴールまでたどり着ければOK。ダメならNG

$move = array(array(1,0),array(0,1),array(-1,0),array(0,-1));

//dfs
function dfs($c, $y, $x){
	global $move;
	global $map;
	global $goal_flag;
	global $yg;
	global $xg;

	if ($y === $yg && $x === $xg){	//終了条件
		$goal_flag = 1;
		return;
	}

	$map[$c][$y][$x] = 0;	//再訪防止
	for ($i=0; $i<=3; $i++){	//上下左右を調査
		$y2 = $y + $move[$i][1];
		$x2 = $x + $move[$i][0];
		if (!empty($map[$c][$y2][$x2]) && $map[$c][$y2][$x2]===1){
			dfs($c, $y2, $x2);
		}
	}
	return;
}

while(1){
	//初期化
	$goal_flag = 0;
	$map = array();
	$usecolor = 0;		//たどる色

	//ファイル読み込み
	fscanf(STDIN, '%d %d', $w, $h);
	//終了判定
	if ($w==0 && $h==0){
		break;
	}
	fscanf(STDIN, '%d %d', $xs, $ys);
	fscanf(STDIN, '%d %d', $xg, $yg);
	fscanf(STDIN, '%d', $n);
	for ($i=0; $i<$n; $i++){
		fscanf(STDIN, '%d %d %d %d', $c, $d, $xblock, $yblock);
		//ブロックがある座標を１に
		if ($d === 0){		//方向転換なし
			for ($p=0; $p<=3; $p++){
				for ($q=0; $q<=1; $q++){
					$map[$c][$yblock + $q][$xblock + $p] = 1;
				}
			}
		} else {
			for ($p=0; $p<=1; $p++){
				for ($q=0; $q<=3; $q++){
					$map[$c][$yblock + $q][$xblock + $p] = 1;
				}
			}
		}
	}

	//スタート地点上の色判定
	for ($c=1; $c<=5; $c++){
		if (!empty($map[$c][$ys][$xs]) && $map[$c][$ys][$xs] === 1){
			$usecolor = $c;
			break;
		}
	}

	//スタート地点から探索
	if ($usecolor !== 0){
		dfs($usecolor, $ys, $xs);
	}
	//出力
	if ($goal_flag === 1){
		echo 'OK';
	} else {
		echo 'NG';
	}
	echo PHP_EOL;
}

Measured memory_bytes: 6776
n, m, x, y = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))

xs_max = max(xs)
ys_min = min(ys)
#print(xs_max, ys_min)
flag = True
for xi in range(xs_max+1, ys_min+1):
  #print(xi)
  if x<xi and xi<=y:
    print('No War')
    flag = False
    break
if flag:
  print('War')


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

count = 0

for i in range(N):
    D1,D2 = list(map(int,input().split()))

    if D1 == D2:
        count += 1
    else:
        count = 0

    if count == 3:
        break

if count == 3:
    print('Yes')
else:
    print('No')

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC132B()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (auto& x : p)
		cin >> x;
	int ct = 0;
	for (int i = 1; i < n - 1; ++i)
	{
		if (p[i - 1] < p[i] && p[i] <= p[i + 1])
			++ct;
		else if (p[i + 1] < p[i] && p[i] <= p[i - 1])
			++ct;
	}
	cout << ct << endl;

}int main()
{
	ABC132B();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<bits//stdc++.h>
#include<functional>
using namespace std;
int main() {
	long double x1,y1,x2,y2,x3,y3,x4,y4;
	while(cin>>x1>>y1>>x2>>y2>>x3>>y3>>x4>>y4){
		if((((y2-y1)*(y4-y3))+((x4-x3)*(x2-x1)))==0) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        char c; cin >> c;
        if(isupper(c)){
            cout << "A" << endl;
        }else{
            cout << "a" << endl;
        }
    }
}


Measured memory_bytes: 3652
#include<iostream>
#include<stack>
#include<string>
#include<sstream>
#include<cstdio>
using namespace std;

int main(){
	stack<int> st;
	string tem;
	int a,b,c;
	while(cin >> tem){
		if(tem == "+"){
			b = st.top();st.pop();
			a = st.top();st.pop();
			c=a+b;
		}else if(tem == "-"){
			b = st.top();st.pop();
			a = st.top();st.pop();
			c=a-b;
		}else if(tem == "*"){
			b = st.top();st.pop();
			a = st.top();st.pop();
			c=a*b;
		}else {
			istringstream is(tem);
			is >> c;
		}
		st.push(c);
	}
	cout<< st.top() << endl;
	return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  char judge[5] = { 0 };
  int ret[4] = { 0 };
  for(int i = 0;i < n;i++) {
    scanf("%s", judge);
    char c = judge[0];
    if (c == 'A') ret[0]++;
    else if(c == 'W') ret[1]++;
    else if(c == 'T') ret[2]++;
    else if(c == 'R') ret[3]++;
  }
  printf("AC x %d\n", ret[0]);
  printf("WA x %d\n", ret[1]);
  printf("TLE x %d\n", ret[2]);
  printf("RE x %d\n", ret[3]);
  return 0;
}
      

Measured memory_bytes: 2156
import static java.lang.System.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double num = sc.nextDouble();
		out.printf("%.6f %.6f%n",num * num * Math.PI,
				   num * 2 * Math.PI);
		sc.close();
	}
}


Measured memory_bytes: 28128
#include <stdio.h>

#define MAX1 100000

typedef struct kk{
  int a[MAX1];
}P;


int binary(P,int);
int n;

int main()
{
  int i,j = 0,m,q;
  P u;

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

  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&m);
    j += binary(u,m);
  }
  printf("%d\n",j);
  return 0;
}

int binary(P x,int y)
{
  int left = 0,right = n;
  int mid;
  while(left < right){
    mid = (left+right)/2;
    if(x.a[mid] == y) return 1;
    else if(y < x.a[mid]) right = mid;
    else left = mid + 1;
  }
  return 0;
}
  



Measured memory_bytes: 2556
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long min = Long.MAX_VALUE;
		
		for(long i = 1; i <= Math.sqrt(N); i++){
			if(N % i == 0)min = Math.min(min, i + (N / i) - 2);
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23636
#include <stdio.h>

int main()
{
	int n;
	scanf("%d",&n);
	int i;
	float cnt=0.0;
	for(i=1;i<=n;i++)
	{
		if(i%2==1)
		{
			cnt=cnt+1.0;
		}
	}
	float p=cnt/n;
	printf("%.10f",p);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(){
	int n,i,data[1000];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&data[i]);
	}
	for(i=n-1;i>=0;i--){
		printf("%d",data[i]);
		if(i!=0){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 1812
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
using namespace std;
int main(){
	int n,a,b,c,d;
	while(~scanf("%d",&n)){
		a=n/1000;
		b=n/100%10;
		c=n/10%10;
		d=n%10;
		if(a+b+c+d==7)  printf("%d+%d+%d+%d=7\n",a,b,c,d);
		else if(a+b+c-d==7)  printf("%d+%d+%d-%d=7\n",a,b,c,d);
		else if(a+b-c+d==7)  printf("%d+%d-%d+%d=7\n",a,b,c,d);
		else if(a-b+c+d==7)  printf("%d-%d+%d+%d=7\n",a,b,c,d);
		else if(a+b-c-d==7) 	printf("%d+%d-%d-%d=7\n",a,b,c,d);
		else if(a-b-c+d==7) 	printf("%d-%d-%d+%d=7\n",a,b,c,d);
		else if(a-b+c-d==7)  printf("%d-%d+%d-%d=7\n",a,b,c,d);
		else if(a-b-c-d==7)  printf("%d-%d+%d-%d=7\n",a,b,c,d);
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll x,n;
    cin>>x>>n;
    ll a[n],ans=0,i,b[102]={},z=0;
    forn(i,n){
        cin>>a[i];b[a[i]]++;
    }
    if(n==0){
        cout<<x<<endl;
        return 0;
    }
    for(i=x;i>=0;i--){
        if(b[i]==0){
            z=i;
            break;
        }
    }
    ans=z;
    for(i=x+1;i<=101;i++){
        if(b[i]==0){
            z=i;
            break;
        }
    }
    if(abs(z-x)<abs(ans-x))ans=z;
    cout<<ans<<endl;

}

Measured memory_bytes: 3640
n=input()
l=len(n)
n=int(n)
ans=0
cnt=0
def fun(num,i):
    global cnt
    if i==l:
        if (num<=n and ("3" in list(str(num))) and ("5" in list(str(num)))
        and ("7" in list(str(num)))):
            cnt+=1
        return
    else:
        if (num<=n and ("3" in list(str(num))) and ("5" in list(str(num)))
        and ("7" in list(str(num)))):
            cnt+=1
        fun(num*10+3,i+1)
        fun(num*10+5,i+1)
        fun(num*10+7,i+1)  
    return
fun(3,1)
fun(5,1)
fun(7,1)
print(cnt)


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  vector<ll> grid(n);
  vector<ll> tired(n-1, 0);
  int teleport = 0;
  ll ans = 0;
  rep(i,n){
    cin >> grid[i];
    if(i>0){
      tired[i-1] = (grid[i] - grid[i - 1]) * a;
      if(tired[i-1] >= b){
        teleport++;
      }else {
        ans += tired[i-1];
      }
    }
  }
  ans += b * teleport;
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>


int main(){
	double a,b,c,d,e,f,g,i,num;
	double y,x;
	
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
	y = (c*d-a*f)/(b*d-a*e);
	x = (c-b*y)/a;
	//y = y + 0.0005;
	//x = x + 0.0005;
	
	printf("%.3lf %.3lf\n",x,y);
	}
	
	return 0;
}

Measured memory_bytes: 648
// AOJ 2527: MLE
// 2017.10.1 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

#define G		49
#define BASE	16384	// 2^14
int f[32768];			// 2^15
long long a[10002]; int sz;

int cmp(long long *a, long long *b)
{
	if (*a == *b) return 0;
	if (*a < *b) return -1;
	return 1;
}

int main()
{
	int n, k, x0, i, cnt, gid;
	unsigned long long x;

	scanf("%d%d%d", &n, &k, &x0);
	if (x0 == 0) { puts("0"); return 0; }

	x = x0;
	i = n; while (i--) {
		f[((long long)x>>G) + BASE]++;
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	cnt = 0;
	for (i = 0; cnt + f[i] < k; i++) cnt += f[i];
	gid = i, k -= cnt;

	x = x0;
	i = n; while (i--) {
		if ((((long long)x >> G) + BASE) == gid) a[sz++] = (long long)x;
		x ^= x << 13;
		x ^= x >> 7;
		x ^= x << 17;
	}
	qsort(a, sz, sizeof(long long), cmp);
	printf("%lld\n", a[k-1]);
	return 0;
}

Measured memory_bytes: 1956
#include<stdio.h>
#define INF -2000000001

int A[500001],n;

int left(int i){return i*2;}
int right(int i){return i*2+1;}
void exchange(int *a,int *b){
  int tmp=*a;
  *a=*b;
  *b=tmp;
}

void maxHeapify(int i){
  int l=left(i);
  int r=right(i);
  int largest;

  if(l<=n&&A[l]>A[i])largest=l;
  else largest=i;

  if(r<=n&&A[r]>A[largest])largest=r;

  if(largest!=i){
    exchange(&A[i],&A[largest]);
    maxHeapify(largest);
  }

}

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&A[i]);
  for(i=n+1;i<500001;i++)A[i]=INF;
  for(i=n/2;i>=1;i--)maxHeapify(i);
  for(i=1;i<=n;i++)printf(" %d",A[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
/*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
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll          long long int
#define pb          push_back
#define pii         pair<ll ,ll >
#define vpii        vector< pii >
#define vi          vector<ll >
#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 )x.size()
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repr(i,a,b) for(ll  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());

#define debug(x)     cout << #x << " " << x << endl;
#define debug_p(x)   cout << #x << " " << x.F << " " << x.S << endl;
#define debug_v(x)   {cout << #x << " "; for (auto ioi : x) cout << ioi << " "; cout << endl;}
#define debug_vp(x)  {cout << #x << " "; for (auto ioi : x) cout << '[' << ioi.F << " " << ioi.S << ']'; cout << endl;}
#define debug_v_v(x) {cout << #x << "/*\n"; for (auto ioi : x) { for (auto ioi2 : ioi) cout << ioi2 << " "; cout << '\n';} cout << "*/" << #x << endl;}

int solve()
{
	ll a,v;cin>>a>>v;
	ll b,w;cin>>b>>w;
	ll t;cin>>t;
	ll d = abs(a-b);
	ll rv = abs(v-w);

	if(d<=t*rv && v>w) cout<<"YES";
	else cout<<"NO";

	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: 3664
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <map>
#include <vector>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)

const int TAN = 1, FUKU = 2;

int main() {
	int n;
	while(cin >> n && n) {
		map<string, int> dic;
		string str;
		getline(cin, str);
		for (int i=0; i<n; i++) {
			getline(cin, str);
			stringstream ss(str);
			while(ss >> str) {
				dic[str]++;
			}
		}
		cin >> str;
		vector<pair<int, string> > ans;
		for (typeof(dic.begin()) it = dic.begin(); it != dic.end(); ++it) {
			if (it->first[0] == str[0]) {
				ans.push_back(make_pair(- it->second, it->first));
			}
		}
		sort(ans.begin(), ans.end());
		if (ans.size() == 0) {
			cout << "NA" << endl;
		} else {
			for (int i=0; i<5 && i<ans.size(); i++) {
				cout << ans[i].second;
				if (i < 4 && i < ans.size() - 1) {
					cout << " ";
				} 
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 952
#include <stdio.h>
#include <string.h>

#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) );

static
unsigned int d[ 10000 ];
static
int bc[ 1024 ];
static
int R, C;

static
int dfs (
  int n
  )
{
  int res;
  int i, j;

  if ( n >= R )
  {
    res = 0;
    
    for ( i = 0; i < C; ++i )
    {
      int t = bc[ d[ i ] ];
      res += MAX( t, R - t );
    }
  }
  else
  {
    res = dfs ( n + 1 );

    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
    res = MAX( res, dfs ( n + 1 ) );
    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
  }

  return ( res );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 0; i < 1024; ++i )
  {
    bc[ i ] = 0;
    for ( j = 1; j <= i; j <<= 1 )
    {
      bc[ i ] += !!( i & j );
    }
  }

  for ( ; ; )
  {
    scanf ( "%d%d", &R, &C );
    if ( !( R | C ) ) break ;

    memset ( d, 0, sizeof ( d ) );
    for ( j = 0; j < R; ++j )
    for ( i = 0; i < C; ++i )
    {
      int t;

      scanf ( "%d", &t );
      d[ i ] |= ( t << j );
    }

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

  return ( 0 );
}

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

int main() {
	int h, w;
	cin >> h >> w;
	char s[101][101];
	for (int i = 1;i <= h;++i) {
		for (int j = 1;j <= w;++j)cin >> s[i][j];
	}for (int i = 1;i <=h;++i) {
		for (int j = 1;j <= w;++j)cout << s[i][j];
		cout << endl;
		for (int j = 1;j <= w;++j)cout << s[i][j];
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<set>
#include<map>
#include<bitset>
#define rep(i,a,b)  for(i=a;i<b;i++)
#define Sort(a)	sort(a.begin(),a.end())
#define rev(a)	reverse(a.begin(),a.end())
#define all(a)	(a).begin(),(a).end()
#define vll vector<long long int>
#define lli long long int
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define db double
#define M 1000000007
#define pi 3.1415926535897932384626433832795028841971
#define INF 1e18

#define MAX 200005

using namespace std;
lli min(lli a,lli b){return a<b?a:b;}
lli min(lli a,lli b,lli c){a=min(a,b);a=min(a,c);return a;}
lli max(lli a,lli b){return a>b?a:b;}
lli max(lli a,lli b,lli c){a=max(a,b);a=max(a,c);return a;}
lli dsum(lli n){lli ans=0;while(n){ans+=(n%10);n/=10;}return ans;}
lli power(lli a,lli b){lli res=1;while(b){if(b&1) res=res*a;a=a*a;b>>=1;}return res;}
lli power(lli a,lli b,lli m){if(b==0)	return 1;if(b==1)	return a%m;lli res=1;a=a%m;while(b){if(b&1){res=(res*a)%m;}a=((a%m)*(a%m))%m;b>>=1;}return res;}
lli Ceil(lli a,lli b){lli res=a/b;if(a%b!=0)	res++;return res;}

template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

lli dxx[]={1,1,0,-1,-1,-1,0,1};
lli dyy[]={0,1,1,1,0,-1,-1,-1};
lli dx[]={1,0,-1,0};
lli dy[]={0,1,0,-1};

struct pll{
	lli x,y;
};
bool comp(pll a,pll b){
	if(a.x==b.x)	return a.y<b.y;
	else	return a.x<b.x;
}
void solve(lli the)
{
	char ch;
	db aa,bb,cc,dd,xx;
	string s1,s2,s3,str;
    lli i,j,k,a,b,c,d,n,m,l,r,x,y,z,low,high,mid,sum=0,ans=0,temp,t;
    cin >> a >> b >> c >> d;
    ans=a*c;
    ans=max(ans,a*d);
    ans=max(ans,b*c);
    ans=max(ans,b*d);
    cout << ans;
    
    
}















int main()
{
	long long int t=1,c=1;
	// scanf("%lld",&t);
	while(t--){
		solve(c);
		c++;
	}
	return 0;
}
/* UJJWAL KESHRI */

Measured memory_bytes: 3628
#include <stdio.h>
#define INF (1<<21)

int min(int,int);

int main() {
    int n, p[101], m[101][101], i, l, j, k;
    scanf("%d",&n);
    for (i=1; i<=n; i++){
        scanf("%d",&p[i-1]);
        scanf("%d",&p[i]);
    }
    
    for(i=1; i<=n; i++) m[i][i] = 0;
    for(l=2; l<=n; l++) {
        for(i=1; i<=n-l+1; i++){
            j = i + l - 1;
            m[i][j] = INF;
            for(k=i; k<=j-1; k++) {
                m[i][j] = min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
            }
        }
    }
    printf("%d\n",m[1][n]);
    return 0;
}

int min(x,y){
    if(x>y) return y;
    else return x;
}

Measured memory_bytes: 636
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>

using std::list;
using std::max;
using std::min;
using std::vector;

#define ARRAY_SIZE (100000+1)

int result[ARRAY_SIZE];

int compute_near_six(int n)
{
  int result = 6;
  while(result <= n) {
    result = result * 6;
  }
  return result / 6;
}

int compute_near_nine(int n)
{
  int result = 9;
  while(result <= n) {
    result = result * 9;
  }
  return result / 9;
}

void solve(int rest)
{
  if(result[rest] != 0) {
    return;
  } else if(rest < 6) {
    result[rest] = rest;
  } else {
    int res = INT_MAX;
    int near_six = compute_near_six(rest);
    int near_nine = compute_near_nine(rest);
    while(1 < near_six) {
      for(int i = 1; i < 6; i++) {
        if(rest < near_six * i) {
          break;
        }
        res = min(result[rest-near_six*i]+i, res);
      }
      near_six = near_six / 6;
    }
    while(1 < near_nine) {
      for(int i = 1; i < 9; i++) {
        if(rest < near_nine * i) {
          break;
        }
        res = min(result[rest-near_nine*i]+i, res);
      }
      near_nine = near_nine / 9;
    }
    result[rest] = res;
  }
}

void init_result()
{
  for(size_t i = 0; i < sizeof(result)/sizeof(*result); i++) {
    result[i] = 0;
  }
}

int main()
{
  int n;
  scanf("%d", &n);
  init_result();
  for(int i = 1; i <= n; i++) {
    solve(i);
  }
  printf("%d\n", result[n]);
  return 0;
}


Measured memory_bytes: 640
fn main() {
    let (n, a, b): (usize, usize, usize) = (read::<usize>(), read::<usize>(), read::<usize>());
    println!("{}", (n / (a + b)) * a + min(a, n % (a + b)));
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n); cin >> a;
	int ans = 0;
	if (a[0] == 1)
	{
		ans++;
		swap(a[0], a[1]);
	}
	FOR(i, 1, n)
	{
		if (a[i] != i + 1) continue;
		if (i < n - 1 && a[i+1] == i+2)
		{
			ans++;
			swap(a[i], a[i + 1]);
		}
		else
		{
			ans++;
			swap(a[i - 1], a[i]);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(2**(n-1)):
        num = ""
        # print("pattern{}: ".format(i), end="")
        # print("a")
        for j in range(n):
            num += s[j]
            if ((i >> j) & 1):
                num += "+"
        # print(eval(num))
        ans += eval(num)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>

#define MAX 250

int h[MAX];

int parent(int i){
  return i / 2;
}

int left(int i){
  return 2 * i;
}

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

main(){
  
  int i, n;
  
  scanf("%d", &n);
  
  for(i = 1; i <= n; i++) scanf("%d", &h[i]);
      
  for(i = 1; i <= n; i++){
    
    printf("node %d: key = %d, ", i, h[i]);
    
    if(i != 1) printf("parent key = %d, ", h[parent(i)]);
    
    if(2 * i <= n) printf("left key = %d, ", h[left(i)]);  
    
    if(2 * i + 1 <= n) printf("right key = %d, ", h[right(i)]);
    
    printf("\n");
    
  }
  
  return 0;
  
}

Measured memory_bytes: 600
#include<stdio.h>

int main() {
	int a;
  	scanf("%d",&a);
  	char str[a+1];
	scanf("%s",str);
	if(a % 2 == 1){
		puts("No");
	}else{
		int flag = 1;
		for(int i = 0;i<a/2;i++){
			if(str[i] != str[i+a/2]){
				flag = 0;
			}
		}
		if(flag){
			puts("Yes");
		}else{
			puts("No");
		}
	}	
  return 0;
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var n = IO.RInt;
            var a = IO.RSInt;

            var now = 1;
            var cnt = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] != now)
                {
                    cnt++;
                }
                else
                {
                    now++;
                }
            }
            WriteLine(now == 1 ? -1 : cnt);
        }

        public class IO
        {
            #region Input
            public static int RInt => int.Parse(ReadLine());
            public static long RLong => long.Parse(ReadLine());
            public static double RDouble => double.Parse(ReadLine());

            public static string[] RSString => ReadLine().Split();
            public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
            public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
            public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static int GCD(int x, int y)
        {
            if (x < y) Swap(ref x, ref y);
            if (y == 0) return x;
            else return GCD(x % y, y);
        }

        public static void Swap(ref int x, ref int y)
        {
            int tmp = x;
            x = y;
            y = tmp;
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

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

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

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

#define MAX 100005
#define INF 1001001001

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

  int m; cin >> m;
  vector<int> b(m);
  rep(i,m) cin >> b[i];

  vector<int> ans;
  set_symmetric_difference(a.begin(), a.end(),
  b.begin(), b.end(),
  inserter(ans, ans.end()));

  for (auto a : ans) cout << a << endl;

  return 0;
}



Measured memory_bytes: 6540
#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
#define ll long long
#define     f           first
#define     s           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<long long,long long>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)

vector<ll> adj[N];
bool visited[N];
const int MAX = 1000001;

// array to store prime factors
int factor[MAX] = { 0 };

// function to generate all prime factors
// of numbers from 1 to 10^6
void generatePrimeFactors()
{
    factor[1] = 1;

    // Initializes all the positions with their value.
    for (int i = 2; i < MAX; i++)
        factor[i] = i;

    // Initializes all multiples of 2 with 2
    for (int i = 4; i < MAX; i += 2)
        factor[i] = 2;

    // A modified version of Sieve of Eratosthenes to
    // store the smallest prime factor that divides
    // every number.
    for (int i = 3; i * i < MAX; i++) {
        // check if it has no prime factor.
        if (factor[i] == i) {
            // Initializes of j starting from i*i
            for (int j = i * i; j < MAX; j += i) {
                // if it has no prime factor before, then
                // stores the smallest prime divisor
                if (factor[j] == j)
                    factor[j] = i;
            }
        }
    }
}

// function to calculate number of factors
int calculateNoOFactors(int n)
{
    if (n == 1)
        return 1;

    int ans = 1;

    // stores the smallest prime number
    // that divides n
    int dup = factor[n];

    // stores the count of number of times
    // a prime number divides n.
    int c = 1;

    // reduces to the next number after prime
    // factorization of n
    int j = n / factor[n];

    // false when prime factorization is done
    while (j != 1) {
        // if the same prime number is dividing n,
        // then we increase the count
        if (factor[j] == dup)
            c += 1;

        /* if its a new prime factor that is factorizing n,
           then we again set c=1 and change dup to the new
           prime factor, and apply the formula explained
           above. */
        else {
            dup = factor[j];
            ans = ans * (c + 1);
            c = 1;
        }

        // prime factorizes a number
        j = j / factor[j];
    }

    // for the last prime factor
    ans = ans * (c + 1);
    return ans;
}
int main()
{

    ll n;
    cin>>n;
    generatePrimeFactors();
    ll ans=0;
    for(int i=1;i<n;i++)
    {
        int k=n-i;
        ans+=calculateNoOFactors(k);
    }
    cout<<ans<<endl;
// getch();
    return 0;
}

Measured memory_bytes: 12216
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    int k,a,b;
    cin>>k>>a>>b;
    int m=a/k;
    int n=m*k;
    while(n<=b)
    {
        if(n>=a)
       {
           cout<<"OK"<<endl;
           return 0;
       }
        n+=k;
    }
    cout<<"NG"<<endl;
    return 0;
    
}


Measured memory_bytes: 3640
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import fractions
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

# ABが水、CDが砂糖、Eがとけられる量、Fが上限
A, B, C, D, E, F = getNM()

dp1 = [0] * 31
dp1[0] = 1
for i in range(1, 31):
    if i >= A:
        dp1[i] = max(dp1[i], dp1[i - A])
    if i >= B:
        dp1[i] = max(dp1[i], dp1[i - B])
waterlist = []
for i in range(31):
    if dp1[i] > 0:
        waterlist.append(i)

dp2 = [0] * 3001
dp2[0] = 1
for i in range(1, 3001):
    if i >= C:
        dp2[i] = max(dp2[i], dp2[i - C])
    if i >= D:
        dp2[i] = max(dp2[i], dp2[i - D])
sugerlist = []
for i in range(3001):
    if dp2[i] > 0:
        sugerlist.append(i)

ans = [0, 0]
concent = 0

for water in waterlist[1:]:
    if 100 * water <= F:
        left = F - (water * 100)
        index = bisect_right(sugerlist, min(left, E * water))
        suger = sugerlist[index - 1]
        optconc = (100 * suger) / (100 * water + suger)
        if optconc >= concent:
            concent = optconc
            ans = [100 * water + suger, suger]
print(*ans)

Measured memory_bytes: 65132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  cout << min(k,n)*x+max(n-k,0)*y << endl;
}


Measured memory_bytes: 256
Scanf.scanf "%d %d" (fun n m ->
    let ab = Array.init n (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in
    let cd = Array.init m (fun _ -> Scanf.scanf " %d %d" (fun a b -> a, b)) in
    for i = 0 to n - 1 do
        let x, y = ab.(i) in
        let rec loop j mip mid =
            if j = m then mip else
            let w, h = cd.(j) in
            let d = abs (x - w) + abs (y - h) in
            if d < mid then loop (j + 1) (j + 1) d
                       else loop (j + 1) mip mid
        in
        Printf.printf "%d\n" @@ loop 0 0 max_int
    done
)

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int a, b, c; cin >> a >> b >> c;
	swap(a, b);
	swap(a, c);
	cout << a << " " << b <<" " << c;
}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

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> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;





int main(){
   //ios::sync_with_stdio(0);
    //freopen("in.in","r",stdin);
    //freopen("out_1.out","w",stdout);
    string s;
    cin>>s;
    
    cout<<s[0]<<s.size() - 2<<s[s.size() - 1]<<endl;
    
}

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

int main() {
    int x, n;
    set<int> pSet;
    cin >> x >> n;
    
    for (int i = 0; i < n; i++) {
        int p;
        cin >> p;
        pSet.insert(p);
    }
    
    int diff = 0;
    while (true) {
        if (pSet.find(x - diff) == pSet.end()) {
        	cout << (x - diff);
            break;
        }
        if (pSet.find(x + diff) == pSet.end()) {
        	cout << (x + diff);
            break;
        }
        diff++;
    }
}


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

int main()
{
	const int N = 3;

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

	sort(p.begin(), p.end(), greater<int>());

	cout << 10 * p[0] + p[1] + p[2] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
    ll N;
    cin >> N;

    VL a(N);
    rep(i, 0, N) cin >> a[i];

    ll L = -1, R = 1e18;
    while(R - L > 1){
        VL tmp(a);
        ll M = L + (R - L)/2;
        ll c = 0;
        auto itr = max_element(ALL(tmp));
        while(*itr >= N){
            ll d = (ll)(*itr/N);
            c += d;
            *itr -= d * (N + 1);
            rep(t, 0, tmp.size()) tmp[t] += d;
            itr = max_element(ALL(tmp));
        }
        if(c <= M) R = M;
        else L = M; 
    }
    cout << R << endl;
    return 0;
}

Measured memory_bytes: 256