akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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 main() {
    ll N; cin >> N;
    vector<vector<ll>> D(N, vector<ll>(2));

    rep(i, N) {
        cin >> D[i][0] >> D[i][1];
    }

    string ans = "No";
    rep(i, N - 2) {
        if (D[i][0] == D[i][1]) {
            if (D[i + 1][0] == D[i + 1][1]) {
                if (D[i + 2][0] == D[i + 2][1]) ans = "Yes";
            }
        }
    }
    cout << ans << endl;

    /*
    ll cnt = 0, ans = 0;
    rep(i, N) {
        bool st = true;
        ll a, b; cin >> a >> b;
        if (a == b) cnt++;
        else st = false;
        
        ans = cnt;
        if (!st) cnt = 0;
    }*/
}

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

#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 998244353
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
vector< pair<int,int> >v;
#define cases int t;cin>>t;while(t--)

ll fi(ll tt){
    if(tt == 0 || tt == 8)return 2;
    else return 3;
}

int main()
{
ll k;cin>>k;
queue<ll>q;
set<ll>s;
for(int i=1;i<=9;i++){
    q.push(i);
    s.insert(i);
}
ll idx = 1;
while(idx!=k){

    ll cur = q.front();
    q.pop();
    ll tmp = cur%10;
    if(tmp != 0){
        ll ne = cur*10 + (tmp-1);
        if(s.find(ne) == s.end()){
            q.push(ne);
        }
    }
        ll ne = cur*10 + (tmp);
        if(s.find(ne) == s.end()){
            q.push(ne);
        }

    if(tmp != 9){
        ll ne = cur*10 + (tmp+1);
        if(s.find(ne) == s.end()){
            q.push(ne);
        }
    }
idx++;
}
cout<<q.front()<<endl;

}


Measured memory_bytes: 1792
import fractions

n, x = map(int, input().split())

city_list = list(map(int, input().split()))

dist_list = []
for city in city_list:
    dist_list.append(abs(city - x))

max_common_value = dist_list.pop(0)

for dist in dist_list:
    # 今までのDと次の都市の距離との最大公約数を見つける
    max_common_value = fractions.gcd(max_common_value, dist)

print(max_common_value)

Measured memory_bytes: 16280
import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            int c = Integer.parseInt(sc.next());
            int max = Math.max(Math.max(a, b), c);
            
            a = max - a;
            b = max - b;
            c = max - c;
            
            if(a%2 + b%2 + c%2 == 0){
            	System.out.println(a/2 + b/2 + c/2);
            }else if(a%2 + b%2 + c%2 == 1){
            	System.out.println(a/2 + b/2 + c/2 + 2);
            }else if(a%2 + b%2 + c%2 == 2){
            	System.out.println(a/2 + b/2 + c/2 + 1);
            }
            
            sc.close();
        }
    }
	

Measured memory_bytes: 22740
#区間の問題は累積和か尺取り法
#区間で条件を満たすものの個数→累積和
#区間の数、条件を満たす区間の最大値最小値→尺取り法
#今回は区間で条件を満たすものの総和→累積和
#二つの端点を同時に扱わなくてはならない
#列車の始まりが区間に含まれるかつ列車の終わりが区間に含まれて＋１である
#つまり二次元累積和を書けばいい
n,m,q=list(map(int,input().split()))
ruiseki=[[0 for i in range(n+1)] for i in range(n+1)]
for i in range(m):
  l,r=list(map(int,input().split()))
  ruiseki[l][r]=ruiseki[l][r]+1
#二次元累積和を計算する
for i in range(0,n+1):
  for j in range(1,n+1):
    ruiseki[i][j]=ruiseki[i][j]+ruiseki[i][j-1]
for i in range(1,n+1):
  for j in range(n+1):
    ruiseki[i][j]=ruiseki[i-1][j]+ruiseki[i][j]

#各クエリに対して累積和を計算
for i in range(q):
  p,q=list(map(int,input().split()))
  print(ruiseki[q][q]-ruiseki[p-1][q]-ruiseki[q][p-1]+ruiseki[p-1][p-1])
  
  

Measured memory_bytes: 18764
#include <iostream>

using namespace std;

int main(void)
{
    uint32_t N, K;
    cin >> N >> K;

    uint32_t ans = K;
    for(uint32_t i = 1; i < N; ++i)
    {
        ans *= (K - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
def main():
    ans = []
    while True:
        m, f, r = map(int, input().split())
        if m == -1 and f == -1 and r == -1:
            break
        s = 0
        if m >= 0:
            s += m
        if f >= 0:
            s += f
        if m == -1 or f == -1:
            ans.append('F')
        elif s >= 80:
            ans.append('A')
        elif 80 > s >= 65:
            ans.append('B')
        elif 65 > s >= 50 or r >= 50:
            ans.append('C')
        elif 50 > s >= 30:
            ans.append('D')
        elif 30 > s:
            ans.append('F')
    for a in ans:
        print(a)


main()



Measured memory_bytes: 5596
n,m = map(int,input().split(" "))
s = [0]*(n+1)
flag = 0
for i in range(m):
    s[int(input())] = 1
    if i>=1 and s[i-1] == 1 and s[i] == 1:
        flag = 1
i = 0
counter = 1
dp = [0 for i in range(n+1)]
dp[0] = 1
for i in range(0,n+1):
    for j in range(i+1,min(i+3,n+1)):
        if s[j] ==0:
            dp[j] += dp[i]
if flag == 1:
    print(0)
else: 
    print(dp[n] % 1000000007)


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int w=0;
	int n;
	cin>>n;
	string s1,s2;
	while (1){
		int a=-1;
		rep(i,4){
			cout<<s1;
			cout << (i/2?'.':'#')<<endl;
			cout << s2;
			cout << (i % 2 ? '.' : '#') << endl;
			string res;
			cin>>res;
			if (res=="end")return 0;
			if (res == "T"){
				a=i;
				break;
			}
		}
		if (a==-1)break;
		s1 += a / 2 ? '.' : '#';
		s2 += a % 2 ? '.' : '#';
		w++;
	}
	while (w < n){
		rep(i, 4){
			cout << (i / 2 ? '.' : '#') <<s1<< endl;
			cout << (i % 2 ? '.' : '#') <<s2<< endl;
			string res;
			cin >> res;
			if (res=="end")return 0;
			if (res == "T"){
				s1 = (i / 2 ? '.' : '#')+s1;
				s2 = (i % 2 ? '.' : '#')+s2;
				w++;
				break;
			}
		}
	}



	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		System.out.println(a*b + " " + (2*a+2*b));
	}

}



Measured memory_bytes: 25932
#include <bits/stdc++.h>
#define all(a) (a).begin(), (a).end()
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1, (i)>=0; (i)--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
ll const MOD = 1e9+7;
ll const INF = 1e18;
using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    if(s.length() > t.length()){
        cout << "GREATER" << endl;
        return 0;
    }else if(s.length() < t.length()){
        cout << "LESS" << endl;
        return 0;
    }else{
        REP(i, s.length()){
            if(s[i] > t[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(s[i] < t[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
    }
    cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
		int count = 0;

		int n = int.Parse(Console.ReadLine());
		for(int i=0; i<n; i++)
		{
			int x = int.Parse(Console.ReadLine());
			if(IsPrime(x))
			{
				count++;
			}
		}

		Console.WriteLine(count);
	}

	static bool IsPrime(int n)
	{
		if(n == 2)
		{
			return true;
		}
		if(n<2 || n%2==0)
		{
			return false;
		}

		int p = (int)Math.Sqrt(n);
		for (int i=3; i<=p; i+=2)
		{
			if (n%i == 0)
			{
				return false;
			}
		}

		return true;
	}
}

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };
ll csb(ll n){ ll count = 0;while (n){ count += n & 1; n >>= 1; } return count;}
string s[100005];
stack <char> st;
ll n;
map<pair<ll, pair<ll, pair <ll,ll>>>, ll> mp;

bool calc(ll idx,ll a,ll b,ll c)
{
    if (mp.find({a, {b, {c, idx}}}) != mp.end())
        return false;
    // cout<<idx<<" "<<a<<" "<<b<<" "<<c<<endl;
    if(a<0 or b<0 or c<0)
        return 0;
    
    if(idx==n)
        return true;

    if(s[idx][0]=='A' and s[idx][1]=='C')
    {
        bool ans=calc(idx+1,a+1,b,c-1);
        if(ans)
        {
            st.push('A');
            return 1;
        }
        ans = calc(idx + 1, a - 1, b, c + 1);
        if (ans)
        {
            st.push('C');
            return 1;
        }
        return 0;
    }
    if (s[idx][0] == 'A' and s[idx][1] == 'B')
    {
        bool ans = calc(idx + 1, a + 1, b - 1, c );
        if (ans)
        {
            st.push('A');
            return 1;
        }
        ans = calc(idx + 1, a - 1, b + 1, c );
        if (ans)
        {
            st.push('B');
            return 1;
        }
        return 0;
    }
    if (s[idx][0] == 'B' and s[idx][1] == 'C')
    {
        bool ans = calc(idx + 1, a , b + 1, c - 1);
        if (ans)
        {
            st.push('B');
            return 1;
        }
        ans = calc(idx + 1, a , b - 1, c + 1);
        if (ans)
        {
            st.push('C');
            return 1;
        }
        return 0;
    }
    mp[{a, {b, {c, idx}}}] = 1;
    return false;
}

int main()
{

fastIO;
ll test,t,i,j,k,m,a,b,c,x,y,u,temp;
cin>>n>>a>>b>>c;
rep(i,0,n)
{
    cin>>s[i];
    sort(s[i].begin(),s[i].end());
}
if(calc(0,a,b,c))
{
    cout<<"Yes\n";
    while(!st.empty())
    {
        cout<<st.top()<<endl;
        st.pop();
    }
}
else
{
    cout<<"No";
}
return 0;
}

Measured memory_bytes: 17844
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] a = new int[n + 1];
		a[n] = -100;
		int[] b = new int[n];
		int[] c = new int[n];
		
		int An = 0;
	
		
		for(int i = 0; i < n; i ++ ) {
			a[i] = sc.nextInt();
	    }

		for(int i = 0; i < n; i ++ ) {
			b[i] = sc.nextInt();
	    }

		for(int i = 0; i < n - 1; i ++ ) {
			c[i] = sc.nextInt();
	    }
		
		for(int i = 0; i < n; i ++ ) {
			An = An + b[i];
			
			if(a[i+1] == a[i]+1)
				An = An + c[a[i] - 1];

		}
		
		System.out.println(An);



	}

}


Measured memory_bytes: 22996
#include <iostream>
#include <map>
#define ll long long
using namespace std;
int main()
{
    ll n; cin >> n;
    ll a[n];
    map<ll,ll> freq;
    for (int i = 0; i < n; i++) {cin >> a[i]; freq[a[i]]++;}
    ll sum = 0;
    for (auto in : freq)
    {
        sum += (in.second*(in.second-1)/2);
    }
    for (int i = 0; i < n; i++)
    {
        cout << sum - freq[a[i]]*(freq[a[i]]-1)/2 + (freq[a[i]]-1)*(freq[a[i]]-2)/2 << "\n";
    }
    return 0;
}


Measured memory_bytes: 11008
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	int ans = 3;


	if (a == b && b != c) {
		printf("2");
	}
	else if (c == b && b != a) {
		printf("2");
	}
	else if (a == c && b != c) {
		printf("2");
	}
	else if (a != b && b != c) {
		printf("3");
	}
	else if (a == b && b == c) {
		printf("1");
	}

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};

int mod_pow(int x, int pow) {
    if(pow == 0) return 1;
    int a = mod_pow(x, pow / 2);
    a = a * a % MOD;
    if(pow % 2 == 1) a *= x;
    return a % MOD;
}

signed main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int n;
    cin >> n;
    int ans = mod_pow(10, n);
    ans += MOD * 2, ans -= mod_pow(9, n) * 2, ans %= MOD;
    ans += mod_pow(8, n), ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

s = input()
print(eval(s))


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


int main(){
  int N,T;

  cin >> N >> T;
  vector<int> c(N);
  vector<int> t(N);
  vector<pair<int,int>> p(N);
  for(int i = 0; i < N; i++){
    cin >> c[i] >> t[i];
  }


  for(int i = 0; i < N; i++){
    p[i] = make_pair(c[i],t[i]);
  }

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

  for(int i = 0; i < N; i++){
    if(p[i].second <= T){ cout << p[i].first; return 0;}
  }

  cout << "TLE" << endl;


    return 0;

}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
import std.random;
import std.range;
import std.functional;
import std.container;
class bt(T)
{
    t!T root;
    bool containsKey(T key)
    {
        return root && root.containsKey(key);
    }
    void insert(T key)
    {
        t!T y = null;
        auto x = root;
        auto z = new t!T(key);
        while (x)
        {
            y = x;
            if (z.key < y.key)
            {
                x = x.left;
            }
            else
            {
                 x = x.right;
            }
        }
        z.parent = y;
        if (!y)
        {
            root = z;
        }
        else
        {
            if (z.key < y.key)
            {
                y.left = z;
            }
            else
            {
                y.right = z;
            }
        }
    }
}
class t(T)
{
    T key;
    this(T k)
    {
        key = k;
    }
    t left, right, parent;
    bool containsKey(T k)
    {
        if (key == k)
            return true;
        if (key > k)
            return left && left.containsKey(k);
        else
            return right && right.containsKey(k);
    }
}
void in_(T)(t!T t)
{
    if (!t)
        return;
    in_(t.left);
    write(" ", t.key);
    in_(t.right);
}
void pre(T)(t!T t)
{
    if (!t)
        return;
    write(" ", t.key);
    pre(t.left);
    pre(t.right);
}
void main()
{
    auto c = readln.strip.to!int;
    bt!int b = new bt!int;
    foreach (_; 0..c)
    {
        auto instr = readln.strip.split(" ");
        if (instr.length == 1)
        {
            in_(b.root);
            writeln();
            pre(b.root);
            writeln();
        }
        else
        {
            auto key = instr[1].to!int;
            if (instr[0] == "find")
            {
                writeln(b.containsKey(key) ? "yes" : "no");
            }
            else
            {
                b.insert(key);
            }
        }
    }
}


Measured memory_bytes: 56100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;

vector<int> G[MX];
int n, A[MX], D[MX];

void dfs(int v){
    D[v]=0;
    vector<int> X;
    for(int x:G[v]){
        dfs(x);
        X.push_back(D[x]);
    }
    sort(X.begin(), X.end(), greater<int>());
    for(int i=0; i<(int)X.size(); i++){
        D[v]=max(D[v], X[i]+i+1);
    }
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=2; i<=n; i++)
        cin>>A[i], G[A[i]].push_back(i);
    dfs(1);
    cout<<D[1]<<'\n';
    return 0;
}

Measured memory_bytes: 14336
n = int(input())
i = 2
ans = n - 1
while i < n:
  if i * i > n:
    i += 1
    break
  if n % i > 0:
    i += 1
    continue
  j = n // i
  ans = min(ans, i + j - 2)
  i += 1
print(ans)

Measured memory_bytes: 3060
program prison
  implicit none
  integer :: n, m, l, r, i, p = 1, q = 1e9
  read(*,*) n, m
  do i = 1, m
    read(*,*) l, r
    p = max(p,l)
    q = min(q,r)
  end do
  write(*,'(i0)') max(q-p+1,0)
end program prison

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


int main() {
    
    ll a;
    cin >> a;
    long double b;
    cin >> b;

    ll c = a*b;

    cout<<c<<endl;

 return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>
#include<math.h>
int count(int ll,int rr)
{
    int c=0;
    int max;
    int j=0;
    int ss;
    if(ll<=3&&rr>=3)c++;
    int lll;
    int llll=ll%4;
    if(llll==0||llll==1)lll=ll+1-llll;
    else lll=ll+5-llll;
    if(lll==1)lll+=4;
    for(int s=lll;s<rr+1;s+=4)
    {
            ss=(s+1)/2;
            max=sqrt(ss)+1;
            int u=3;
            while(u<=max&&j==0)
            {
                if(ss%u==0)j=1;
                u+=2;
            }
            max=sqrt(s)+1;
            int t=3;
            while(t<=max&&j==0)
            {
                if(s%t==0)j=1;
                t+=2;
            }
        if(j==0)c++;
        j=0;
    }
    return c;
}
 
 
int main(void)
{
    int q;
    int ans;
    scanf("%d",&q);
    int l[q];
    int r[q];
  	int unko08658932[100001];
  	unko08658932[0]=0;
  	for(int i=1;i<100001;i++)unko08658932[i]=unko08658932[i-1]+count(i,i);
    for(int p=0;p<q;p++)scanf("%d%d",&l[p],&r[p]);
    for(int w=0;w<q;w++)
    {
        ans=unko08658932[r[w]]-unko08658932[l[w]-1];
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var A = GetIntArray().OrderBy(a => a).ToArray();
            var ans = A[2] - A[0];
            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

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

/*
M_bΣ_{α∈A}a_α = M_aΣ_{α∈A}b_α 
⇔Σ_{α∈A}(M_b*a_α - M_a*b_α) = 0
*/


int main() {
	int maxnum = 1000000;
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, ma, mb;
	cin >> n >> ma>>mb;
	int plus[4000], minus[4000];
	plus[0] = 0;
	minus[0] = 0;
	int ans = maxnum;
	for (int i = 1; i < 4000; i++) {
		plus[i] = maxnum;
		minus[i] = maxnum;
	}
	int a, b, ab, c;
	for (int i = 0; i < n; i++) {
		cin >> a>> b>> c;
		ab = mb * a - ma * b;
		if (ab == 0) {
			ans = min(ans, c);
		}
		else if (ab > 0) {
			for (int i = 4000 - ab - 1;i>=0; i--) {
				plus[i + ab] = min(plus[i + ab], plus[i] + c);
			}
		}
		else {
			for (int i = 4000 + ab - 1;i>=0; i--) {
				minus[i - ab] = min(minus[i - ab], minus[i] + c);
			}
		}
	}
	for (int i = 1; i < 4000 ; i++) {
		ans = min(ans, plus[i] + minus[i]);
	}
	if (ans == maxnum) ans = -1;
	cout << ans << endl;

	return 0;
}

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

int main() {
   int n;
   cin >> n;
   string ans="No";
   for(int i=0;i<=25;i++){
      for(int j=0;j<=15;j++){
         if(4*i+7*j==n)
         ans="Yes";
      }
   }
   cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

ans = 0


def dfs(h):
    global ans
    if not h:
        return
    minh = min(h)
    ans += minh
    if minh != 0:
        for i in range(len(h)):
            h[i] -= minh
    while h[0] == 0 and not h:
        h = h[1:]
    while h[-1] == 0 and not h:
        h = h[:-1]
    pos_zero = []
    pos_zero.append(-1)
    for i in range(len(h)):
        if h[i] == 0:
            pos_zero.append(i)
    pos_zero.append(len(h))
    for i in range(len(pos_zero)-1):
        dfs(h[pos_zero[i]+1:pos_zero[i+1]])


dfs(H)
print(ans)


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << '\n'

using ll = long long;
using namespace std;

const int N = 1e5 + 1;
int h[N], dp[N], n;

int solve(int index)
{
	if (dp[index] != -1)
		return dp[index];
	
	return dp[index] = min(abs(h[index] - h[index - 1]) + solve(index - 1), abs(h[index] - h[index - 2]) + solve(index - 2));
}

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

#ifdef LOCAL_DEFINE
	freopen("in.txt", "r", stdin);
#endif

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

	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);

	cout << solve(n - 1);

	
	return 0;
}

Measured memory_bytes: 3328
n=int(input())
L=list(map(int,input().split()))
L=sorted(L)
s=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if L[i]!=L[j]:
            for k in range(j+1,n):
                if L[j]!=L[k] and L[i]+L[j]>L[k]:
                    s+=1
                elif L[i]+L[j]<=L[k]:
                    break
print(s)                    

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

using namespace std;

int main()
{
  int n;
  int x;
  cin>>n;
  x=n%10 ;
  if(x==3){cout<<"bon";}
  else if(x==0 || x==1 || x==6 || x==8){cout<<"pon";}
  else{cout<<"hon";}
  
  
  
  return 0;
}

Measured memory_bytes: 3592
N = int(input())
A = list(map(int,input().split()))
A.sort()
MAX = max(A)+1#A[-1]+1
num_tmp = [0]*MAX

for a in A:
    num_tmp[a] += 1
    if num_tmp[a] == 1:
        for i in range(2*a,MAX,a):
            num_tmp[i] = 2

print(num_tmp.count(1))

Measured memory_bytes: 32212
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n, m;
    cin >> n >> m;
    cout << (n*(n-1)/2 + m*(m-1)/2) << endl;
    return 0;
}

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

const int MAX = 510000;
const int mod = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

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

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

    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 0;
    ll mod = 1e9+7;
    ll ret = 0;
    ll f=1;
    ll inv[n]={};
    inv[1]=1;
    for(int i=1;i<n;i++){
        f *= i;
        f%=mod;
        if(i>=2)inv[i] = mod - inv[mod%i] * (mod/i) %mod;
    }
    for(int i=1;i<n;i++){
        ret += f*inv[i];
        ret %= mod;
        ans += (a[i]-a[i-1]) * ret;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
a, b, c, d, e, f = map(int, input().split())
water_reps = []
sugar_reps = []
for i in range(0, 3001, 100 * a):
    for j in range(0, 3001, 100 * b):
        if 0 < (i + j):
            water_reps.append(i + j)
for i in range(0, min(30 * e, 1501), c):
    for j in range(0, min(30 * e, 1501), d):
        sugar_reps.append(i + j)
water_reps = list(set(water_reps))
sugar_reps = list(set(sugar_reps))
water_reps.sort()
sugar_reps.sort()
ans = [(water_reps[0] + sugar_reps[0]), sugar_reps[0]]
for water in water_reps:
    for sugar in sugar_reps:
        if sugar <= (water // 100) * e and (water + sugar) <= f:
            conc = sugar / (water + sugar)
            if (ans[1] / ans[0]) < conc:
                ans = [(water + sugar), sugar]
print(*ans)


Measured memory_bytes: 98564
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll i = min(b - 1, n);
  ll ans = ll(floor(a * i / b) - a * floor(i / b));

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

Measured memory_bytes: 3632
X,K,D = map(int,input().split())
X = abs(X)
if D == X:
    if K%2 == 0:
        ans = X
    else:
        ans = 0
else:
    if X >= K*D:
        ans = X - K*D
    else:
        X_min = X - D*(X // D)#最小値
        if (K - (X//D)) % 2 == 0:
            ans = X_min
        else:
            if abs(X_min-D) == X_min:
                ans = X_min
            else:
                ans = min(abs(X_min-D),X_min+D)
print(ans)    

Measured memory_bytes: 9196
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: isize,
    m: isize,
    c: isize,
    b: [isize; m],
    a: [[isize; m]; n]
    }
    let ret = calc(n,m,c,b,a);
    println!("{}", ret);
}

fn calc(n: isize, m: isize, c:isize, b:Vec<isize>, a:Vec<Vec<isize>>) -> isize {
    a.iter().filter(|row| ip(&b, row)+c > 0).map(|_| 1).sum()
}

fn ip(v1:&Vec<isize>, v2:&Vec<isize>) -> isize {
    if v1.len() != v2.len() { panic!("vector length does not match")}
    let mut ret = 0;
    for i in 0..v1.len() {
        ret += v1[i] * v2[i];
    }
    ret
}

Measured memory_bytes: 4352
#include <iostream>
#include<vector>
using namespace std;
int main() {
    int n,k;cin>>n>>k;
    vector<int> a(n);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=k+1;i<=n;i++) {
        if (a[i - k - 1] >= a[i - 1]) {
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4044
//k-th common divisor
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	int a,b,k;
	cin>>a>>b>>k;
	int* x = new int[100];
	int t;
	if(a > b) t = b;
	else t = a;
	int ptr=0;
	for (int i = t; i > 0; i--)
	{
		if(a%i == 0 && b%i == 0){
			x[ptr] = i;
			ptr++;
		}
	}
	cout<<x[k-1]<<endl;
	return 0;
}

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

int main() {
    int N; cin >> N;
    vector<int> V(N), C(N), D(N);
    for(int i = 0; i < N; i++) cin >> V[i];
    for(int i = 0; i < N; i++) cin >> C[i];
    for(int i = 0; i < N; i++) D[i] = V[i] - C[i];
    int ans = 0;
    for(int i = 0; i < N; i++) if(D[i] > 0) ans += D[i];
    cout << ans << endl;

}

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

int main(){
  int N;
  cin>>N;
  vector<int> H(N);
  for(int &i:H)
    cin>>i;
  bool bo=false;
  for(int i=N-2;i>=0;i--){
    if(H[i]>H[i+1])
      if(H[i]-H[i+1]>1){
        cout<<"No"<<endl;
        return 0;
      }else
        H[i]--;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define P 1000000007
#define ll long long
map<ll,ll>f;
ll solve(ll x)
{
	if(f[x]) return f[x];
	f[x]=((solve(x/2)+solve((x-1)/2))%P+solve((x-2)/2))%P;
	return f[x];
}

int main()
{
	f[0]=1,f[1]=2;
	ll n;
	cin>>n;
	cout<<solve(n);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int maxn=100100;
 
long long dp[maxn];
long long h[maxn];
long long n,k;
 
int main () {
	
	cin >> n >> k;
	for (int i=0;i<n;++i){
		cin >> h[i];
	}
	
		dp[1]=abs(h[1]-h[0]);
		dp[0]=0;
		
	for (int i=2;i<n;++i){
		
		dp[i]=10e15+10;
		for (int j=1;j<=k;j++)
		{
			if (j > i)continue;
			dp[i]=min(abs(h[i]-h[i-j])+dp[i-j], dp[i]);
		}	
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include"bits/stdc++.h"
using namespace std;
void solve()
{
  int n; cin>>n;  vector<int>a(n); for(int i=0;i<=n-1;i++) cin>>a[i]; 
  int ans=0; 
  if(n<3){ cout<<0<<"\n"; return; }
  for(int i=0;i<=n-3;i++)
  {
    for(int j=i+1;j<=n-2;j++)
    {
      for(int k=j+1;k<=n-1;k++)
      {
        if(a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k])
        {
          if(a[i]+a[j]>a[k] and a[i]+a[k]>a[j] and a[j]+a[k]>a[i]) ans++; 
        }
      }
    }
  }
  cout<<ans<<"\n"; return; 
}
int main()
{
  ios_base::sync_with_stdio(false); 
  cin.tie(nullptr); 
  int t=1; 
  while(t--)
  {
    solve(); 
  }
  return 0; 
}

Measured memory_bytes: 3644
#include <iostream>
#include <cmath>

using namespace std;

int const nmax = 1e5;
int v[1 + nmax];
int cost[1 + nmax];

int main() {

  int n, k;
  cin >> n >> k;
  for(int i = 1;i <= n;i++){
    cin >> v[i];
    cost[i] = 999999999;
    for(int j = i-1;j >= i-k && j > 0;j--){
      cost[i] = min(cost[i], cost[j] + abs(v[i] - v[j]));
    }
    if(i == 1){
      cost[i] = 0;
    }
  }
  cout << cost[n];
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

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

    int ans = X;
    rep(i,D){
        if (i == 0) {
            ans += N;
            continue;
        }

        rep(j,N){
            if (i % A[j] == 0){
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int fun(int i);
int main()
{
  int n,a,b;
  cin >>n>>a>>b;
  
  int sum=0;
  
   int i , ans;
   for(i=1;i<=n;i++)
    {
        ans=fun(i);
        
        if(a<=ans && ans<=b)
        {
            sum=sum+i;
        }
    }
  
  cout <<sum<<endl;
  
  return 0;
  
}
int fun(int i)
{
    int sum1=0;
    
    while(i!=0)
    {  
        sum1+=i%10;
        i/=10;
    }
    
    return sum1;    
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int H,W;
    cin>>H>>W;
    vector<string> s(H);
    REP(i,H) cin>>s[i];
    vector<string> ans = s;
    REP(i,H) {
        REP(j,W) {
            if (s[i][j] == '.') {
                int bomb = 0;
                if (i != 0 && s[i-1][j] == '#') bomb++;
                if (i != H-1 && s[i+1][j] == '#') bomb++;
                if (j != 0 && s[i][j-1] == '#') bomb++;
                if (j != W-1 && s[i][j+1] == '#') bomb++;
                if (i != 0 && j != 0 && s[i-1][j-1] == '#') bomb++;
                if (i != 0 && j != W-1 && s[i-1][j+1] == '#') bomb++;
                if (i != H-1 && j != 0 && s[i+1][j-1] == '#') bomb++;
                if (i != H-1 && j != W-1 && s[i+1][j+1] == '#') bomb++;
                ans[i][j] = (char)('0' + bomb);
            }
        }
    }
    REP(i,H) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
//const ll mod=1e+9+7;
int main(void){
    ll n,m;cin>>n>>m;
    bool res[n];
    fill(res,res+n,false);
    vector<int> WA(n,0);
    int AC=0;
    rep(i,m){
        int p;
        string s;cin>>p>>s;p--;
        if(res[p]==false){
            if(s=="AC"){
                res[p]=true;
                AC++;
            }else{
                WA[p]++;
            }
        }
    }
    int WAsum=0;
    rep(i,n){
        if(res[i])WAsum+=WA[i];
    }
    cout<<AC<<" "<<WAsum<<endl;
}


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

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

const int MAXN = 2e5 + 21;

long long n, m;
long long top, x;
long long q[MAXN], c[MAXN], ans[MAXN];

void solve(long long len, int id) {
    int tmp;    
    if (!len) 
        return;
    if (len <= q[1]) {
        ans[0] += c[id]; 
        ans[len] -= c[id];
    }
    else {
        tmp = upper_bound(q + 1, q + m + 1, len) - q - 1;
        c[tmp] += len / q[tmp] * c[id];
        solve(len % q[tmp], id);
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    q[top = 1] = n;
    
    for (int i = 0; i < m; i++) {
        cin >> x;
        while (top && q[top] >= x) 
            top--;

        q[++top] = x;
    }

    c[top] = 1;
    m = top;

    for (int i = m - 1; i > 0; i--) {
        c[i] += q[i + 1] / q[i] * c[i + 1]; 
        solve(q[i + 1] % q[i], i + 1);
    }

    ans[q[1]] -= c[1];
    ans[0] += c[1];

    cout << ans[0] << '\n';
    for (int i = 1; i < n; i++) {
        ans[i] += ans[i - 1];
        cout << ans[i] << '\n';
    }
    return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;
int h, w, k;
const int IINF = 1 << 30;

bool is_valid(int y, int x)
{
    return 0 <= y && y < h && 0 <= x && x < w;
}

int main()
{
    cin >> h >> w >> k;
    vector<string> g(h);
    rep(i, h) cin >> g[i];
    int sy, sx;
    rep(i, h)
    {
        rep(j, w)
        {
            if (g[i][j] == 'S')
            {
                sy = i;
                sx = j;
            }
        }
    }
    vector<vector<int>> dist(h, vector<int>(w, IINF));
    deque<pair<pair<int, int>, int>> que;
    que.push_back({{sy, sx}, 0});
    int dy[4] = {1, -1, 0, 0};
    int dx[4] = {0, 0, 1, -1};

    while (!que.empty())
    {
        auto cur = que.front().first;
        auto cost = que.front().second;
        que.pop_front();
        if (dist[cur.first][cur.second] <= cost)
        {
            continue;
        }
        dist[cur.first][cur.second] = cost;
        rep(i, 4)
        {
            int ny = cur.first + dy[i];
            int nx = cur.second + dx[i];
            if (is_valid(ny, nx) && g[ny][nx] == '.')
            {
                que.push_back({{ny, nx}, cost + 1});
            }
        }
    }

    int ans = IINF;
    rep(i, h) rep(j, w)
    {
        if (dist[i][j] <= k)
        {
            int mindist = min({i, j, h - 1 - i, w - 1 - j});
            //cerr << mindist << endl;
            ans = min(ans, 1 + (mindist + k - 1) / k);
            if (mindist == 0)
            {
                ans = 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <vector>

int main(){
	std::vector<int> rail;
	std::vector<int> out;
	int a;

	while(std::cin >> a){
		if(a != 0){
			rail.push_back(a);
		}else if(a == 0){
			out.push_back(rail.back());
			rail.pop_back();
		}
	}

	for(int i=0; i<(int)out.size(); ++i){
		std::cout << out.at(i) << std::endl;
	}
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Vec = vector<ll>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}
template <typename T>
ll pow2(const T n){return (1LL << n);}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	string s;
	cin >> s;
	ll n = s.size();

	ll a = 0, b = 0;
	for(ll i = 0; i < n; ++i){
		if(s[i] == '0') a++;
		else b++;
	}
	cout << min(a, b)*2 << endl;

	return 0;
}


Measured memory_bytes: 1020
# https://atcoder.jp/contests/agc027/tasks/agc027_a
n, x = map(int, input().split())
nums = [int(i) for i in input().split()]
nums.sort()


c = 0
for i in range(n):
    if x >= nums[i]:
        c += 1
        x -= nums[i]
    else:
        print(c)
        break
else:
    if x == 0:
        print(c)
    else:
        print(c - 1)

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())
#define AsceSort(a) sort(a.begin(),a.end())

using namespace std;
typedef long long ll;

int main(void) {
	int k,i;
	cin >> k>>i;
	cout << k - i + 1 << endl;
	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char a[11],b[11],c[11];
    char ch;
    int la, lb, lc;
    scanf("%s", &a);
    scanf("%c",&ch);
    scanf("%s",&b);
    scanf("%s",&c);
    la=strlen(a);
    lb=strlen(b);
    lc=strlen(c);
    if(la>=1&&la<=10&&lb>=1&&lb<=10&&lc>=1&&lc<=10)
	{
	if((a[la-1]==b[0])&&(b[lb-1]==c[0]))
    printf("YES\n");
    else
		printf("NO\n");
	}
    return 0;
}

Measured memory_bytes: 1660
// C - Distinct or Not
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T> vector<T> inarr(int s,int e, T init=0){
	vector<T> v;T x;
	for(int i=0;i<s;++i)v.push_back(init);
	for(int i=s;i<e;++i){cin>>x;v.push_back(x);}
	return v;
}

int N;
vi A;

string solve(){
	sort(all(A));
	vi X(N);
	rp(i,1,N) X[i] = A[i] - A[i-1];
	rp(i,1,N) if(X[i] == 0) return "NO";
	return "YES";
}

int main(){
	cin>>N;
	A = inarr<int>(0,N);
	cout<< solve() <<endl;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}

int main()
{
    fastio();
    long double a,b;
    cin>>a>>b;
    long double c = a*b;
    cout<<fixed<<(ll)c<<endl;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;
	int A[N-1];
	map<int, int> mp;
	rep(i,N-1){
		cin >> A[i];
		mp[A[i]]++;
	}
	rep(i,N){
		cout << mp[i+1] << endl;
	}
	
}

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

int main() {
    int X;
    cin>>X;
    for(int i=0; i<=100000; ++i){
        if (100*i<=X and X<=105*i){
            cout<<1<<endl;
        return 0;}
    }
            cout<<0<<endl;
    return 0;
    }


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

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

int main() {
    int64_t a, b;
    cin >> a >> b;
    
    cout << lcm(a, b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
//#include<iostream>
using namespace std;
int s[25], n;

int solve(int i, int m)
{
  if(m == 0) return 1;
  if(i >= n) return 0;
  int ans = solve(i+1, m) || solve(i+1, m-s[i]);
  return ans;
}
int main()
{

  scanf("%d", &n);
  for(int i = 0; i<n; i++)
  {
    scanf("%d", &s[i]);
  }
  int q;
  scanf("%d", &q);
  int m;
  for(int i=0; i<q; i++)
  {
    scanf("%d", &m);
    if(solve(0,m)) printf("yes\n");
    else printf("no\n");
  }

  return 0;
}



Measured memory_bytes: 2684