akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define v(t,n) vector<t> n
void _din() {}
void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void qsortv(vector<T>& v) { qsort(v.data(), v.size(), sizeof(T), [](const void*a, const void*b)->int {if ((*(T*)a) < (*(T*)b))return -1; if ((*(T*)a) == (*(T*)b))return 0; return 1; }); }
template <typename T, typename F>inline void qsortv(vector<T>& v, F func) { qsort(v.data(), v.size(), sizeof(T), func); }
template <typename T>inline void sortv(vector<T>& v) { sort(v.begin(), v.end()); }
// ==================================================

int main()
{
	din(int, n, k);

	dout(n%k ? 1 : 0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int f[101][101];
int memo[101][101];

int calc(int x, int y){
	int res=INT_MAX/2;

	if(x==0 && y==0){
		return 0;
	}

	if(y>0){
		if(f[x][y-1]==0 && f[x][y]==1){
			if(memo[x][y-1]!=-1)res=min(res, memo[x][y-1]+1);
			else res=min(res,calc(x,y-1)+1);
			memo[x][y]=res;
		}else{
			if(memo[x][y-1]!=-1)res=min(res,memo[x][y-1]);
			else res=min(res, calc(x,y-1));
			memo[x][y]=res;
		}
	}

	if(x>0){
		if(f[x-1][y]==0 && f[x][y]==1){
			if(memo[x-1][y]!=-1)res=min(res, memo[x-1][y]+1);
			else res=min(res,calc(x-1,y)+1);
			memo[x][y]=res;
		}else{
			if(memo[x-1][y]!=-1)res=min(res, memo[x-1][y]);
			else res=min(res,calc(x-1,y));
			memo[x][y]=res;
		}
	}

	return res;
}

int main(){
	int h,w;
	cin>>h>>w;
	REP(i,h)REP(j,w){
		char c;
		cin>>c;
		if(c=='#')f[i][j]=0;
		else if(c=='.')f[i][j]=1;
		memo[i][j]=-1;
	}
	int ans=calc(h-1,w-1);
	if(f[h-1][w-1]==0)ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
string s;
cin>>s;
set<char>set;
set.insert(s.at(0));
set.insert(s.at(1));
set.insert(s.at(2));
if(set.size()==3){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}









Measured memory_bytes: 256
q = int(input())
dic = {}
for _ in range(q):
    op = list(input().split())
    if op[0]=='0':dic[op[1]] = op[2]
    elif op[0]=='1':
        print ( dic[op[1]] if op[1] in dic.keys() else 0)
    else:
        try :dic.pop(op[1])
        except :pass


Measured memory_bytes: 41888
#!/usr/bin/env ruby

card = [];spade =[];heart =[];clover = [];dia = []

number = gets.to_i
0.upto(number - 1) do |index|
    card = gets.split
    case card[0]
    when "S" then
        spade << card[1].to_i
    when "H" then
        heart << card[1].to_i
    when "C" then
        clover << card[1].to_i
    when "D" then
        dia << card[1].to_i
    end
end
spade.sort;heart.sort;clover.sort;dia.sort

1.upto(13) do |number|
    if !spade.include?(number) then
        puts "S #{number}"
    end
end

1.upto(13) do |number|
    if !heart.include?(number) then
        puts "H #{number}"
    end
end

1.upto(13) do |number|
    if !clover.include?(number) then
        puts "C #{number}"
    end
end

1.upto(13) do |number|
    if !dia.include?(number) then
        puts "D #{number}"
    end
end


Measured memory_bytes: 6888
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);

	REP(i, N) {
		cin >> a[i];
	}

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

	cout << a[N - 1] - a[0] << endl;

	return 0;
}


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

using namespace std;
int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	int a[n+1];
	for (int i = 0; i < n+1; i++) {
		cin >> a[i];
	}
	int b[n];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
	}
	
	long ans = 0;
	int ii = 0;
	int ip = 0;
	for (int i = 0; i < n; i++) {
		if (i >= 1) {
			ii = min(a[i] - ip, b[i]);
		} else {
			ii = min(a[i], b[i]);
		}
		ip = min(a[i+1], b[i] - ii);
//		cout << "ii = " << ii << ", ip = " << ip << endl;
		ans += ii + ip;
//		cout << i << ":合計" << ans << "体倒した" << endl;
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 1024
import  itertools

n=int(input())
q=list(map(int,input().split()))
la=int(input())
m=list(map(int,input().split()))
nums=[0,1]
tmp=[]
for cnt in itertools.product(nums, repeat=n):
    gh = list(cnt)
    ans = 0
    for j in range(len(gh)):
        if gh[j] == 1:
            ans += q[j]
    tmp.append(ans)

for i in range(la):
    if m[i] in tmp:
        print("yes")
    else:
        print("no")


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

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

int main() {
    int n,m; cin >> n >> m;
    vector<int> dish(m,0);

    rep(i, n) {
        int tmp; cin >> tmp;
        rep(j, tmp) {
            int tmp2; cin >> tmp2;
            dish[tmp2-1]++;
        }
    }

    int ans = 0;
    rep(i, m) if(dish[i] == n) ans++;

    cout << ans << endl;

    return 0;

}


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

struct Edge {
  int to, cap, rev;
  Edge(int to_, int cap_, int rev_) : to(to_), cap(cap_) , rev(rev_) { }
};

int INF = (int)1e9;
const int MAX_V = 400;
vector<Edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from, int to, int cap) {
  G[from].emplace_back(to, cap, G[to].size());
  G[to].emplace_back(from, 0, G[from].size() - 1);
}

int find_flow(int v, int t, int f) {
  if(v == t) return f;
  used[v] = true;
  for(Edge &e : G[v]) {
    if(used[e.to] == false && e.cap > 0) {
      int d = find_flow(e.to, t, min(f, e.cap));
      if(d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s, int t) {
  int flow = 0;
  while(true) {
    fill(used, used + MAX_V, false);
    int f = find_flow(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

int main() {
  int N;
  int a[100],b[100],c[100],d[100];
  cin >> N;
  for(int i=0;i<N;i++) cin >>a[i] >> b[i];
  for(int i=0;i<N;i++) cin >>c[i] >> d[i];
  int src = 2*N;
  int dst = 2*N+1;
  for(int i = 0; i < N; i++) {
    add_edge(src, i, 1);
  }
  for(int i = 0; i < N; i++) {
    add_edge(N + i, dst, 1);
  }
  for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(a[i] < c[j] && b[i] < d[j]) add_edge(i, N + j, 1);
    }
  }
  cout << max_flow(src, dst) << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstring>

using namespace std;
typedef long long LL;

int C[200][200] , a[200] ;
LL dp[200][200];

void yu()
{
	C[1][0] = C[1][1] = 1;  
    for (int i = 2; i < 190; i++){  
        C[i][0] = 1;  
        for (int j = 1; j < 190; j++)  
            C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]);  
    }
}

int main()
{
	int n , cnt = 0;
	scanf("%d",&n);
	for(int i = 1 ; i <= n ; i++){
		scanf("%d",&a[i]);
	}
	if(a[1] % 2 == 0) dp[1][1] = 2 , dp[1][0] = 1;
	else dp[1][0] = 2 , dp[1][1] = 1;
	for(int i = 2 ; i <= n ; i++){
		if(a[i] % 2 == 1){
			dp[i][0] = 2 * (dp[i - 1][0] + dp[i - 1][1]) + dp[i - 1][0];
			dp[i][1] = dp[i - 1][1];
		}
		else{
			dp[i][0] = 3 * dp[i - 1][0] + dp[i - 1][1];
			dp[i][1] = 2 * dp[i - 1][1];
		}
	}
	printf("%lld\n",dp[n][0]);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String s = inp.next();
        String t = inp.next();
        int a = inp.nextInt();
        int b = inp.nextInt();
        String u = inp.next();
        if (s.equals(u)) {
            System.out.printf("%d %d", a - 1, b);
        }
        else {
            System.out.printf("%d %d", a, b - 1);
        }
        System.out.println();
    }
}

Measured memory_bytes: 20948
using System;


public class C{
	
	public static void Main(){
	
		string[] args;

		args = Console.ReadLine().Split(' ');
		long d = Int64.Parse(args[0]);
		long g = Int64.Parse(args[1]);
		
		long[] p = new long[d+1];
		long[] c = new long[d+1];
		
		for( int i = 1; i <= d; i++ ){
			args = Console.ReadLine().Split(' ');
			p[i] = Int64.Parse(args[0]);
			c[i] = Int64.Parse(args[1]);			
		}
		
		long[] total = new long[d+1];
		for( int i = 1; i <= d; i++ ){
			total[i] = 100 * i * p[i] + c[i];
		}
		
		long minNumSolve = Int64.MaxValue; 
		for( int s = 0; s < (1 << (int)d); s++ ){
			
			long point = 0;
			long numSolve = 0;
			
			for( int i = 0; i < d; i++ ){
				if( ((s >> i) & 1) == 0 ) continue;
				point += total[i+1];
				numSolve += p[i+1];
			}

			if( point >= g ){
				if( numSolve < minNumSolve ) minNumSolve = numSolve;
				continue;			
			}
			
			for( int i = 0; i < d; i++ ){
				long rest = g - point;
				if( ((s >> i) & 1) == 1 ) continue;
				if( rest > 100 * (i + 1) * p[i+1] ) continue;
				long tmpNumSolve = numSolve;
				tmpNumSolve += rest / ( 100 * (i + 1) );
				if( rest % (100 * (i + 1)) != 0 ) tmpNumSolve++;
				if( tmpNumSolve < minNumSolve ) minNumSolve = tmpNumSolve;
			}		
			
		}
		
		Console.WriteLine(minNumSolve);		
		
	}

}

Measured memory_bytes: 11092
m[99],a[99],b[99],i,j,M,B;main(n){for(;scanf("%d",&n)*n;puts(B?"NG":"OK")){for(i=n;i--;B=0)scanf("%d%d%d",m+i,a+i,b+i);for(i=n;i--;B|=M>150)for(M=0,j=n;j--;)M+=a[i]>=a[j]&a[i]<b[j]?m[j]:0;}}

Measured memory_bytes: 0
N, C = map(int, input().split())
X_V = [list(map(int, input().split())) for i in range(N)]
max_en = 0
point = [0] * (N+1)
point_back = [0] * (N+1)
point_rev = [0] * (N+1)
point_rev_back = [0] * (N+1)
max_point = [0] * (N+1)
max_point_back = [0] * (N+1)
max_point_rev = [0] * (N+1)
max_point_rev_back = [0] * (N+1)
for i, x_v in enumerate(X_V):
    # print(X_V[N-i-1])
    if i == 0:
        point[i+1] = x_v[1] - x_v[0]
        point_back[i+1] = x_v[1] - x_v[0]*2
        point_rev[i+1] = X_V[N-i-1][1] - (C-X_V[N-i-1][0])
        point_rev_back[i+1] = X_V[N-i-1][1] - (C-X_V[N-i-1][0])*2
    else:
        point[i+1] = point[i]+x_v[1] - (x_v[0]-X_V[i - 1][0])
        point_back[i+1] = point[i+1] - x_v[0]
        point_rev[i+1] = point_rev[i]+X_V[N-i-1][1] - (X_V[N-i][0]-X_V[N-i-1][0])
        point_rev_back[i+1] = point_rev[i+1] - (C-X_V[N-i-1][0])

    max_point[i + 1] = max(max_point[i], point[i + 1])
    max_point_back[i + 1] = max(max_point_back[i], point_back[i + 1])
    max_point_rev[i + 1] = max(max_point_rev[i], point_rev[i + 1])
    max_point_rev_back[i + 1] = max(max_point_rev_back[i],
                                    point_rev_back[i + 1])

# print(point)
# print(point_back)
# print(point_rev)
# print(point_rev_back)
for i in range(N+1):
    # print(i, N-i)
    max_en = max(max_en, max_point[i], max_point_rev[N-i], max_point_back[i] + max_point_rev[N-i],
                 max_point[i] + max_point_rev_back[N-i])
    # for j in range(N+1):
    #     if i + j > N:
    #         break
    #     else:
    #         if j == 0:
    #             max_en = max(max_en, point[i])
    #             # print(i, j, point[i])
    #         elif i == 0:
    #             max_en = max(max_en, point_rev[j])
    #             # print(i, j, point_rev[j])
    #         else:
    #             max_en = max(max_en, point_back[i] + point_rev[j], point[i] + point_rev_back[j])
    #             # print(i, j, point_back[i] + point_rev_back[j])

print(max_en)

Measured memory_bytes: 72152
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int q = cin.nextInt();
			if(q==-1){
				break;
			}
			double eps = 0.00001*q;
			double x = q/2;
			while(true){
				if(Math.abs(Math.pow(x, 3)-q) < eps){
					break;
				}
				x = x-(Math.pow(x, 3)-q) / (3*Math.pow(x, 2));
			}
			System.out.printf("%.6f\n",x);
		}

	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
int dp[3001][3001];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin>>s>>t;
    rep(i,0,s.length()){
        rep(j,0,t.length()){
            if(s[i]==t[j]) dp[i+1][j+1]=dp[i][j]+1;
            else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }
    string c;
    int i=s.length()-1,j=t.length()-1;
    while(i>=0&&j>=0){
        while(i>=0&&j>=0){
            if(s[i]==t[j]&&dp[i+1][j+1]==dp[i][j]+1) {
                c+=t[j];
                i--;
                j--;
            }
            else {
                if(dp[i+1][j+1]==dp[i][j+1]){
                    i--;
                }
                else if(dp[i+1][j+1]==dp[i+1][j]){
                    j--;
                }
            }
        }
    }
    rep(i,0,c.length()){
        cout <<c[c.length()-i-1];
    }
    cout<<"\n";
}

Measured memory_bytes: 35456
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    set<int> st;
    st.insert(0);
    for (int i = 0; i < n; i++) {
        set<int> next;
        for (set<int>::iterator j = st.begin(); j != st.end(); j++) {
            next.insert(*j);
            next.insert(*j + s[i]);
        }
        st = next;
    }

    int res = 0;
    for (set<int>::reverse_iterator i = st.rbegin(); i != st.rend(); i++) {
        if (*i % 10 != 0) {
            res = *i;
            break;
        }
    }

    cout << res << endl;
}


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

using namespace std;
#define ll long long

int main()
{
    ll int N, answer = 0;
    vector<ll> list(5);
    cin >> N;

    for (int i = 0; i < 5; i++)
    {
        cin >> list[i];
    }
    answer = 4 + (N + (*min_element(list.begin(), list.end()) - 1)) / *min_element(list.begin(), list.end());

    cout << answer << endl;
    return 0;
}

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

using namespace std;

int n, b[102], a[102], sum;

int main()
{
  cin >> n;
  for (int i = 1; i < n; i++)
    cin >> b[i];
  a[1] = b[1];
  a[n] = b[n - 1];
  for (int i = 2; i < n; i++) {
    a[i] = min(b[i - 1], b[i]);
  }
  for (int i = 1; i <= n; i++)
    sum += a[i];
  cout << sum;
	return 0;
}


Measured memory_bytes: 256
import           Control.Monad
import           Data.Array.IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector                 as VB
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
getIntegerVec n =
  VB.unfoldrN n (BS.readInteger . BS.dropWhile isSpace) <$> BS.getLine

main = do
  n <- getInt
  as <- getIntegerVec n

  cs <- VM.new 61
  forM_ [0..60] $ \i -> VM.write cs i (0::Int)

  forM_ [0..n-1] $ \i -> do
    let a = as VB.! i
    forM_ [0..60] $ \j ->
      when (testBit a j) $ do
        c <- VM.read cs j
        VM.write cs j (c+1)

  let calc i x | i == -1 = return $ x `mod` 1000000007
               | otherwise = do
                   c <- VM.read cs i
                   let c1 = fromIntegral c :: Integer
                       c2 = fromIntegral (n-c) :: Integer
                       x' = c1 * c2 * bit i
                   calc (i-1) (x+x')
  ans <- calc 60 0
  print ans

Measured memory_bytes: 63868
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		while(s.hasNextInt()) {
			int c = 0;
			int n = s.nextInt();
			for (int i = 0; i <= 9; ++i) {
				for(int j = 0; j <= 9; ++j) {
					for(int k = 0; k <= 9; ++k) {
						for(int l = 0; l <= 9; ++l) {
							int sum = i + j + k + l;
							if(n == sum) {
								c++;
								break;
							} else if (n < sum) {
								break;
							}
						}
					}
				}
			}
			System.out.println(c);
		}
	}
}

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

int main()
{
    int a, b, cnt=0;
    cin >> a >> b;
    for(int i=a; i<=b; i++)
    {
        string s;
        s = to_string(i);
        if(s[0]==s[4] && s[1]==s[3])
        {
            cnt++;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define Rep(i, s, n) for (int i = (int)s; i < (int)n; i++)
typedef long long ll;

int len(int n) {
    return log10(n) + 1;
}

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

    int n;
    cin >> n;
    int h[n];
    rep (i, n) {
        cin >> h[i];
    }
    if (n > 1) {
        h[0]--;
        Rep (i, 1, n - 1) {
            if (h[i] > h[i-1]) h[i]--;
            if (h[i+1] - h[i] < 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

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

int main() {
	int N = 1, M = 1;
	ll result = 0;
	cin >> N >> M;
	priority_queue<ll> q;

	repeat(i, N) {
		ll a = 0;
		cin >> a;
		q.push(a);
	}

	repeat(i, M) {
		ll v = q.top();
		q.pop();
		q.push(v/2);
	}

	repeat(i, N) {
		result += q.top();
		q.pop();
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 1400
def main():
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))
    
    max_A = max(A)
    B = sorted(A)
    max2_A = B[N-2]

    if max_A == max2_A:
        for i in range(N):
            print(max_A)
        exit()
    
    for i in range(N):
        tmp=A[i]
        if tmp == max_A:
            print(max2_A)
        else:
            print(max_A)

if __name__=="__main__":
    main()

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

int main() {
  int N;
  cin >> N;
  
  double sum;
  
  for (int i = 0; i < N; i++) {
    double x;
    string u;
    cin >> x >> u;
    
    if (u == "JPY") {
      sum += x;
    }
    else {
      sum += x * 380000.0;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#define NDEBUG
NDEBUG


#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <memory>
#include <queue>
#include <random>


using namespace std;

template<class T>
using vec = std::vector<T>;


typedef int64_t i64;


// TC_REMOVE_BEGIN
/// caide keep
bool __hack = std::ios::sync_with_stdio(false);
/// caide keep
auto __hack1 = cin.tie(nullptr);
// TC_REMOVE_END


// Section with adoption of array and vector algorithms.


//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//
//template <class T> using StdTree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


namespace template_util {
    

    constexpr int bytecount(uint64_t x) {
        return x ? 1 + bytecount(x >> 8) : 0;
    }

    template<int N>
    struct bytetype {
        
    };

    
    /// caide keep
    template<uint64_t N>
    struct minimal_uint : bytetype<bytecount(N)> {
    };
}


template<class T>
T next(istream& in) {
    T ret;
    in >> ret;
    return ret;
}


void solve(istream& in, ostream& out) {
  auto n = next<int>(in);
  vec<int> divisors(n + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = i; j <= n; j += i) {
      ++divisors[j];
    }
  }
//  dbg(divisors);
  i64 res = 0;
  for (i64 i = 1; i <= n; ++i) {
    res += i * divisors[(int)i];
  }
  out << res << "\n";
}

//#include <fstream>


int main() {
//  ifstream fin("bridges.in");
//  ofstream fout("bridges.out");
    solve(cin, cout);
//  solve(fin, fout);
    return 0;
}



Measured memory_bytes: 42244
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	A,B,K = inputMap()

	if A > 0:
		if A <= K:
			K = K-A
			A = 0
			#print(K)
		else:
			print("{} {}".format(A-K, B))
			sys.exit()

	#print("{} {}".format(A, B))
	if B > 0:
		if B <= K:
			print("{} {}".format(0, 0))
			sys.exit()
		else:
			#print("ss")
			B = B-K
			print("{} {}".format(A, B))
			sys.exit()

	print("{} {}".format(A, B))




if __name__ == "__main__":
	main()


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

int main() {
	string s;
	cin>>s;
	LL cnt=0;
	LL i=0,j=s.length()-1;
	while(i<j){
	    if(s[i]==s[j]){
	        i++;
	        j--;
	    }
	    else{
	        cnt++;
	        i++;
	        j--;
	    }
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int h, w, k;
char c[1000010];
string s[1000010];
int dx[4]={1,-1,0,0}, dy[4]={0, 0, 1, -1};
bool valid(int x, int y){
	return (x>=0) && (y>=0) && (x<h) && (y<w) && (s[x][y]=='.');
}
vector<int> dis[1000010], dis1[5][1000010];
vector<int> dp[5][1000010];
int dis_to_first_block(int x, int y, int dr){
    if(dp[dr][x][y]!=-1){
        return dp[dr][x][y];
    }
    int xx=x+dx[dr];
    int yy=y+dy[dr];
    if(valid(xx, yy)){
        dp[dr][x][y]=min(k, 1+dis_to_first_block(xx, yy, dr));
    }
    else{
        dp[dr][x][y]=0;
    }
    return dp[dr][x][y];
}
int main(){
    while(cin>>h>>w>>k){
        ll ans=0;
        int x1, x2, y1, y2;
        scanf("%d%d%d%d",&x1,&y1, &x2, &y2);--x1;--x2;--y1;--y2;
        for(int i=0; i<h; ++i){
	        	dis[i].resize(w+50, -1);
        	for(int j=0; j<5; ++j){
	           dis1[j][i].resize(w+50, 1000010);
               dp[j][i].resize(w+50, -1);
            }
	        	// for(int j=0; j<w; ++j)c[j]='.';c[w]='\0';
        	cin>>s[i];
        }
        queue<pair<pair<int, int>, int>>q;
        q.push(mk(mk(x1, y1), 0));
        int x, y, xx, yy, cost, dir;
        pair<pair<int, int>, int> tmp;
        while(!q.empty()){
        	tmp=q.front();
        	q.pop();
        	x=tmp.fs.fs;y=tmp.fs.sc;cost=tmp.sc;
        	// cout<<x<<" "<<y<<" "<<cost<<endl;
        	if(dis[tmp.fs.fs][tmp.fs.sc]!=-1){assert(dis[x][y]<=cost);
        		continue;
        	}
        	// cout<<"*"<<x<<" "<<y<<" "<<cost<<endl;
        	dis[x][y]=cost;
        	// if(x==x2&&y==y2){
        	// 	break;
        	// }
        	for(int i=0; i<4; ++i){
                int tmp1=dis_to_first_block(x, y, i);
        		for(int j=tmp1; j>=0; --j){
	        		xx=x+dx[i]*j;
	        		yy=y+dy[i]*j;
	        		if(valid(xx, yy)){
	        			if(dis1[i][xx][yy]<=cost+1){
	        				break;
	        			}
	        			dis1[i][xx][yy]=cost+1;
		        		q.push(mk(mk(xx, yy),cost+1));
	        		}
	        		else{
	        			break;
	        		}
        		}
        	}
        }
        printf("%d\n",dis[x2][y2]);
    }
  return 0;
}




Measured memory_bytes: 355024
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 2018-6-10 21:02:48
# Powered by Visual Studio Code
#

a, b = gets.chomp.split(" ").map{|i| i.to_i}

x = b - a

puts x * (x + 1) / 2 - b

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
  cin>>n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >>vec[i];
  }
   sort(vec.begin(), vec.end()); 
   reverse(vec.begin(), vec.end());
  int wa=0;
  vec[0]=(vec[0])/2;
  for(int i=0;i<n;i++)
    wa += vec[i];
  
  
 cout << wa <<endl; 
 
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int n;
    cin >> n;
    bool ok = false;
    for(int i = 0; i <= n/4; i++){
        int rem = n - i * 4;
        if(rem == 0 || rem % 7 == 0)
            ok = true;
    }
    cout << (ok ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;
using data = pair<int, P>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> g(h);
    for(int i = 0; i < h; i++) {
        cin >> g[i];
    }
    queue<data> que;
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            if(g[i][j] == '#') {
                que.emplace(data(0, P(i, j)));
            }
        }
    }
    int ans = 0;
    while(que.size()) {
        auto now = que.front();
        que.pop();
        ans = now.first;
        int ni, nj;
        for(int i = 0; i < 4; i++) {
            ni = now.second.first + dy[i];
            nj = now.second.second + dx[i];
            if(0 <= ni && ni < h && 0 <= nj && nj < w && g[ni][nj] == '.') {
                g[ni][nj] = '#';
                que.emplace(data(now.first + 1, P(ni, nj)));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 13456
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	string s , t ;
	cin>> s >> t ;
	ll cnt=0;
	for(ll i=0;i<3;i++){
		if(s[i]==t[i])cnt++;
	}
	cout<<cnt<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll n, m; cin >> n >> m;
    vector<pair<ll, ll>> a(m);
    rep(i, m){
        cin >> a[i].first >> a[i].second;
        a[i].first--, a[i].second--;
    }
    vector<bool> flag1(n, false);
    vector<bool> flag2(n, false);

    rep(i, m){
        if(a[i].first == 0)flag1[a[i].second] = true;
        if(a[i].second == n - 1)flag2[a[i].first] = true;
    }
    rep(i, n){
        if(flag1[i] && flag2[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 3456
fn main() {
    let x: i32 = read();
    if x >= 1200 {
        println!("ARC");
    } else {
        println!("ABC");
    }
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = 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")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define isSquare(x) (sqrt(x)*sqrt(x) == x)
template<class T>bool chmax(T &a, const T &b) {if(a<b){a = b; return 1;} return 0; };
template<class T>bool chmin(T &a, const T &b) {if(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep(i, 0, N) cin >> A[i];
    sort(ALL(A));
    int g = A[0];
    rep(i, 1, N) g = __gcd(g, A[i]);
    if(K % g == 0 && K <= A[N-1]) puts("POSSIBLE");
    else puts("IMPOSSIBLE");

    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
string a[2],b;
string s[2][1001];
int p[2];
void dfs(int x){
  r(i,a[x].size()){
    if(a[x][i]=='"'){
      i++;s[x][p[x]]+='"';
      while(i<a[x].size()&&a[x][i]!='"')s[x][p[x]]+=a[x][i++];
      p[x]++;
    }else{
      while(i<a[x].size()&&a[x][i]!='"')s[x][p[x]]+=a[x][i++];
      p[x]++;
      i--;
    }
  }
}
main(){
  while(cin>>a[0],a[0]!="."){
    cin>>a[1];
    p[0]=p[1]=0;
    r(i,2)r(j,1001)s[i][j]="";
    r(i,2)dfs(i);
    if(p[0]!=p[1])cout<<"DIFFERENT"<<endl;
    else{
      int f1=0,f2=0;
      r(i,p[0])if(s[0][i]!=s[1][i]){
        if(s[0][i][0]=='"'&&s[1][i][0]=='"')f1++;
        else f2++;
      }
      if(f2||f1>1)cout<<"DIFFERENT"<<endl;
      else if(f1)cout<<"CLOSE"<<endl;
      else cout<<"IDENTICAL"<<endl;
    }
  }
}


Measured memory_bytes: 3196
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *p = map(int, read().split())
p += [0]
cnt = 0
for i, pp in enumerate(p):
    if (i + 1) == pp:
        p[i + 1] = 0
        cnt += 1
print(cnt)


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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

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

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}



int main(){
    int a,b;cin >> a >> b;
    if(a%3==0||b%3==0||(a+b)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
#define inf (ll)1e18+1
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll h,a;
    cin>>h>>a;
    ll ans=ceil(h*1.0/a);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
inline void read(int &x){
    x=0;static char ch;static bool flag;flag = false;
    while(ch=getchar(),ch<'!');if(ch == '-') ch=getchar(),flag = true;
    while(x=10*x+ch-'0',ch=getchar(),ch>'!');if(flag) x=-x;
}
#define rg register int
#define rep(i,a,b) for(rg i=(a);i<=(b);++i)
#define per(i,a,b) for(rg i=(a);i>=(b);--i)
const int maxn = 512;
const int zero = 250;
int fa[maxn],siz[maxn],oud[maxn],ind[maxn];bool h[maxn];
int find(int x){return fa[x] == x ? x : fa[x] = find(fa[x]);}
inline void Union(int x,int y){
    x = find(x);y = find(y);
    if(x == y) {++siz[x];return ;}
    fa[x] = y;siz[y] += siz[x] + 1;
}
int main(){
    int n,H;read(n);read(H);
    rep(i,1,H)  fa[i+zero] = i+zero,siz[i+zero] = 1;
    rep(i,-H,-1)fa[i+zero] = i+zero,siz[i+zero] = 1;
    int a,b,c,d;
    rep(i,1,n){
        int x,y;
        read(a);read(b);read(c);read(d);
        if(c == 0) x = a;else x = -c;
        if(d == 0) y = -b;else y = d;
        ++ oud[x + zero];++ ind[y + zero];
        Union(x+zero,y+zero);
    }
    rep(i,1,H)  if(oud[i+zero] < ind[i+zero]) return puts("NO"),0;
    rep(i,-H,-1)if(ind[i+zero] < oud[i+zero]) return puts("NO"),0;
    rep(i,1,H)  h[find(i+zero)] |= (ind[i+zero]!=oud[i+zero]);
    rep(i,-H,-1)h[find(i+zero)] |= (ind[i+zero]!=oud[i+zero]);
    rep(i,1,H)  if(siz[find(i+zero)] > 1 && (find(i+zero) == i+zero) && (h[i+zero] == false)) return puts("NO"),0;
    rep(i,-H,-1)if(siz[find(i+zero)] > 1 && (find(i+zero) == i+zero) && (h[i+zero] == false)) return puts("NO"),0;
    puts("YES");
    return 0;
}

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, m;
vector<P> e[100000];
map<int, vector<int>> color[1000000];
set<int> colored[100000];
int dis[100000];
queue<int> que;

void dfs(int v, int col) {
    if (colored[v].count(col)) return;
    colored[v].insert(col);
    rep(i,color[col][v].size()) {
        int to = color[col][v][i];
        if (to == -1) continue;
        if (dis[to] < dis[v]) continue;
        if (dis[to] == INF) que.push(to);
        dis[to] = dis[v];
        color[col][v][i] = -1;
        dfs(to, col);
    }
    vector<int> emp;
    color[col][v] = emp;
}

int main() {
    cin >> n >> m;
    rep(i,n) dis[i] = INF;
    dis[0] = 0;
    rep(i,m) {
        int p, q, c;
        cin >> p >> q >> c;
        p--; q--; c--;
        e[p].push_back(P(q,c));
        color[c][p].push_back(q);
        e[q].push_back(P(p,c));
        color[c][q].push_back(p);
    }
    que.push(0);
    while (!que.empty()) {
        int q = que.front(); que.pop();
        rep(i,e[q].size()) {
            int to = e[q][i].first, c = e[q][i].second;
            if (dis[to] <= dis[q]) continue;
            if (colored[to].count(c)) continue;
            if (dis[to] == INF) que.push(to);
            dis[to] = dis[q]+1;
            dfs(to, c);
        }
    }
    if (dis[n-1] == INF) dis[n-1] = -1;
    cout << dis[n-1] << endl;
}
































Measured memory_bytes: 112628
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

unordered_map<char, vector<long>> positions;

void solve() {
  string s, t;
  cin >> s >> t;
  rep (i, s.size()) {
    positions[s[i]].push_back(i);
  }
  long count = 0;
  long current = -1;
  for (char c: t) {
    if (positions[c].size() == 0) {
      cout << -1 << endl;
      return;
    }
    current += 1;
    count += current / s.size();
    current %= s.size();
    auto it = lower_bound(positions[c].begin(), positions[c].end(), current);
    if (it == positions[c].end()) {
      count += 1;
      current = positions[c][0];
    } else {
      current = *it;
    }
  }
  long result = count * s.size() + current + 1;
  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
	ll N, L, T; cin >> N >> L >> T;
	vector<ll>X(N), W(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> W[i];
	}

	vector<pair<double,int>>Y(N);
	for (int i = 0; i < N; i++) {
		ll y = X[i];
		if (W[i] == 1) {
			y += T;
			y %= L;
		}
		else {
			y -= T%L;
			y = (y + L) % L;
		}
		Y[i].first = y + 0.1*(3-W[i]);
		Y[i].second = i;
	}
	sort(Y.begin(), Y.end());

	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (W[0] != W[i]) {
			cnt += 2 * (T/L);

			int D;
			if (W[0] == 1) {
				if (X[0] > X[i])D = X[i] + L - X[0];
				else D = X[i] - X[0];
			}
			else {
				if (X[0] < X[i])D = X[0] + L - X[i];
				else D = X[0] - X[i];
			}

			int tmpT = T%L;
			if (D <= 2 * tmpT)cnt++;
			tmpT -= ceil(D / 2.);
			D = L - D % 2;
			if (D <= 2 * tmpT)cnt++;
		}
	}

	cnt %= N;
	for (int i = 0; i < N; i++) {
		if (Y[i].second == 0) {
			cnt = (N + i + (W[0] == 1 ? -cnt : cnt)) % N;
			break;
		}
	}

	for (int i = cnt; i < N; i++) {
		cout << (int)Y[i].first << endl;
	}
	for (int i = 0; i < cnt; i++) {
		cout << (int)Y[i].first << endl;
	}

    return 0;
}



Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cassert>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

long long cnt;
int l;
int A[1000000];
int B[1000000];
int N;
vector<int> G;

void insertionSort(int A[], int N, int g){
    for (int i=g; i<N; i++){
        int v = A[i];
        int j = i-g;
        while(j>=0&&A[j]>v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
}

void shellsort(int A[], int N){
    for (int h=1; ; ){
        if (h>N) break;
        G.push_back(h);
        h = 3*h+1;
    }
    
    for(int i=G.size()-1; i>=0; i--){
        insertionSort(A,N,G[i]);
    }
}

int main(){
    cin >> N;
    for (int i=0; i<N; i++) cin >> A[i];
    cnt = 0;
    shellsort(A,N);
    
    cout << G.size()<< endl;
    for (int i=G.size()-1; i>=0; i--){
        cout << G[i];
        if (i) cout << ' ';
    }
    cout << endl;
    cout << cnt << endl;
    for (int i=0; i<N; i++) cout << A[i] << endl;
}




Measured memory_bytes: 7004