akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			m = scanner.nextInt();
			n = scanner.nextInt();
			if ((m | n) == 0)
				break;
			M = new HashMap<Integer, Integer>();
			h = 1;
			a = new int[n][m];
			pairs = new Pair[24];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++) {
					int t = scanner.nextInt();
					if (t == 0) {
						a[i][j] = -1;
					} else if (t == 1) {
						pairs[h] = new Pair(i, j);
						a[i][j] = h++;
					} else {
						pairs[0] = new Pair(i, j);
						a[i][j] = 0;
					}
				}
			System.out.println(slove(0, 1));
		}
	}

	private int slove(int cur, int bit) {
		int k = cur << 24 | bit;
		if (M.containsKey(k))
			return M.get(k);
		int res = 0;
		for (int[] mo : move) {
			int y = pairs[cur].y;
			int x = pairs[cur].x;
			while (true) {
				y += mo[0];
				x += mo[1];
				if (!isOK(y, x))
					break;
				if (a[y][x] == 0)
					if (Integer.bitCount(bit) == h) {
						return res + 1;
					}
				if (a[y][x] >= 1) {
					if ((bit >> a[y][x] & 1) == 1)
						continue;
					res += slove(a[y][x], bit | 1 << a[y][x]);
					break;
				}
			}
		}
		M.put(k, res);
		return res;
	}

	private boolean isOK(int y, int x) {
		if (0 <= y && y < n && 0 <= x && x < m)
			return true;
		return false;
	}
	class Pair{
		int y,x;

		public Pair(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}
		
	}

	int m, n, h;
	Pair[] pairs;
	int[][] a;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
	Map<Integer, Integer> M;
}

Measured memory_bytes: 178724
using System;
using System.Linq;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i; (i = int.Parse(Console.ReadLine())) != 0;) {
                var d = new int [4][] { new [] {0, 0, 0, 0}, new [] {0, 0, 0, 0}, new [] {0, 0, 0, 0}, new [] {0, 0, 0, 0} };
                for(int m = 0; m < i; ++m) {
                    var value = Console.ReadLine().Split();
                    var input = new int[9];
                    for(int n = 0; n < 9; ++n) {
                        input[n] = int.Parse(value[n]);
                    }
                    var time = 0;
                    for(int n = 1; n <= 8; ++n) {
                        time += input[n] * ((n & 1) == 1 ? 60 : 1);
                    }
                    if(m <= 1) {
                        if(m == 0) {
                            d[0] = d[1] = d[2] = d[3] = new [] { input[0], time };
                        }
                        else { 
                            d[d[0][1] > time ? 0 : 1] = d[d[0][1] > time ? 2 : 3] = new [] { input[0], time };
                        }
                        continue;
                    }
                    if(time < d[1][1]) {
                        d[1] = new [] { input[0], time };
                        if(time < d[0][1]) {
                            d[1] = d[0];
                            d[0] = new [] { input[0], time };
                        }
                    }
                    if(time > d[2][1]) {
                        d[2] = new [] { input[0], time };
                        if(time > d[3][1]) {
                            d[2] = d[3];
                            d[3] = new [] { input[0], time };
                        }
                    }
                }
                Console.WriteLine("{0}{3}{1}{3}{2}", d[0][0], d[1][0], d[2][0], System.Environment.NewLine);
            }
        }
    }
}

Measured memory_bytes: 5832
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

struct node {
    vector<int> dis = {-1, -1, -1}, to;
};

using graph = vector<node>;

int main() {
    int n, m; cin >> n >> m;
    graph g(n);
    REP(i, m) {
        int u, v; cin >> u >> v;
        --u; --v;
        g[u].to.push_back(v);
    }

    int s, t; cin >> s >> t;
    --s; --t;

    queue<pair<int, int>> q;
    q.push({s, 0});
    g[s].dis[0] = 0;

    while(!q.empty()) {
        auto front = q.front(); q.pop();
        int now = front.first, mod = front.second;

        if(now == t && mod == 0) {
            cout << g[now].dis[mod] / 3 << endl;
            return 0;
        }

        for(int next : g[now].to) {
            if(g[next].dis[(mod + 1) % 3] == -1) {
                g[next].dis[(mod + 1) % 3] = g[now].dis[mod] + 1;
                q.push({next, (mod + 1) % 3});
            }
        }
    }

    cout << -1 << endl;

    return 0;
}


Measured memory_bytes: 11136
n = int(input())

a = [int(input()) for i in range(n)]
ma1 = max(a)
ma2 = a.count(ma1)

for i in range(n):
    if a[i] == ma1:
        if ma2 == 1:
            a[i] = 1
            print(max(a))
            a[i] = ma1
        else:
            print(ma1)
    else:
        print(ma1)

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

int damerau_levenshtein_distance(const string &a,const string &b,const int alphabet_size){
    unordered_map<int,int> da;
    unordered_map<int,unordered_map<int,int>> d;
    int maxdist=a.size()+b.size();
    d[-1][-1]=maxdist;
    for(int i=0; i<=a.size(); ++i){
        d[i][-1]=maxdist;
        d[i][0]=i;
    }
    for(int i=0; i<=b.size(); ++i){
        d[-1][i]=maxdist;
        d[0][i]=i;
    }
    for(int i=1; i<=a.size(); ++i){
        int db=0;
        for(int j=1; j<=b.size(); ++j){
            int k=da[b[j-1]],l=db,cost;
            if(a[i-1]==b[j-1]){
                cost=0;
                db=j;
            }else cost=1;
            d[i][j]=min({d[i-1][j-1]+cost,d[i][j-1]+1,d[i-1][j]+1,d[k-1][l-1]+(i-k-1)+1+(j-l-1)});
        }
        da[a[i-1]]=i;
    }
    return d[a.size()][b.size()];
}

void solve(int n){
    int d;
    vector<string> name(n);
    cin >> d;
    rep(i,0,n) cin >> name[i];
    sort(name.begin(),name.end());

    int count=0;
    rep(i,0,n){
        rep(j,i+1,n){
            if(damerau_levenshtein_distance(name[i],name[j],26)>d) continue;
            ++count;
            cout << name[i] << "," << name[j] << endl;
        }
    }
    cout << count << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    for(;;){
        int n;
        cin >> n;
        if(!n) break;
        solve(n);
    }
    return 0;
}

Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define RI register int

using namespace std;

int const MAXN = 1e6 + 5;
char s[MAXN], t[MAXN];
queue <int> q;

int main() {
  int n; scanf("%d", &n);
  scanf("%s %s", s + 1, t + 1);
  for (RI i = 1; i <= n; ++i)
    if (s[i] != t[i]) break;
    else if (i == n) return puts("0"), 0;
  int snow = n, ans = 0;
  for (RI i = n; i; --i) {
    while (i > 1 && t[i] == t[i - 1]) --i;
    while (snow && (snow > i || s[snow] != t[i])) --snow;
    if (!snow) return puts("-1"), 0;
    while (!q.empty() && (int(q.front() - q.size()) >= i)) q.pop();
    if (snow != i) q.push(snow);
    ans = max(ans, int(q.size() + 1));
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 6272
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class CompetitiveProgrammingProgram
{
    static long Gcd(long a, long b)
    {
        long[] v = new long[] { a, b };
        while (v[1] != 0) { v = new long[] { v[1], v[0] % v[1] }; }
        return v[0];
    }
    static long Lcm(long a, long b)
    {
        return a / Gcd(a, b) * b;
    }
    class Node<T>
    {
        private int m_height;
        private Node<T> m_parent;
        public T Item { get; private set; }
        public Node(T item)
        {
            m_height = 0;
            m_parent = this;
            Item = item;
        }
        public Node<T> Find()
        {
            if (m_parent == this) { return this; }

            Node<T> parent = m_parent.Find();
            m_parent = parent;
            return parent;
        }
        public static void Unite(Node<T> a, Node<T> b)
        {
            Node<T> p = a.Find();
            Node<T> q = b.Find();
            if (p.m_height < q.m_height)
            {
                p.m_parent = q;
                q.m_height = Math.Max(p.m_height + 1, q.m_height);
            }
            else
            {
                q.m_parent = p;
                p.m_height = Math.Max(q.m_height + 1, p.m_height);
            }
        }
    }
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int K = int.Parse(input[1]);
        int[] A = new int[N];
        input = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++)
        {
            A[i] = int.Parse(input[i]);
        }
        int ma = 1000000000;
        int mi = 1;
        while (mi <= ma)
        {
            if (mi == ma)
                break;
            int mid = (ma + mi) / 2;
            int cnt = K;
            for (int i = 0; i < N; i++)
            {
                cnt -= (A[i]-1) / mid;
            }
            if (cnt < 0)
                mi = mid + 1;
            else
                ma = mid;
        }
        Console.WriteLine(ma.ToString());
    }
}

Measured memory_bytes: 43956
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){int ret=1;do{if(y&1)ret=(ll)ret*x%md;x=(ll)x*x%md;}while(y>>=1);return ret;}
int n,T;
pair<int,int>p[200005];
bool cmp(pair<int,int>a,pair<int,int>b){
	return a.first*(b.second+1)>b.first*(a.second+1);
}
int dp[50];
void update(int a,int b){
	for(int i=48;i>=0;i--){
		dp[i+1]=min(dp[i+1],(a+1)*(dp[i]+1)+b);
		dp[i+1]=min(dp[i+1],inf);
	}
}
signed main(){
	cin>>n>>T;
	for(int i=1;i<=n;i++){
		cin>>p[i].first>>p[i].second;
	}
	sort(p+1,p+n+1,cmp);
	vector<int>got;
	for(int i=1;i<50;i++)dp[i]=inf;
	dp[0]=0;
	for(int i=1;i<=n;i++){
		if(p[i].first==0){
			got.push_back(p[i].second+1);
		}else{ 
			update(p[i].first,p[i].second);
		}
	}
	sort(got.begin(),got.end());
	for(int i=1;i<got.size();i++)got[i]+=got[i-1];
	int ans=0;
	for(int i=0;i<50;i++){
//		cerr<<i<<" "<<dp[i]<<endl;
		if(dp[i]<=T)ans=max(ans,i+(upper_bound(got.begin(),got.end(),T-dp[i])-got.begin()));
	}
	if(dp[49]<inf)while(1);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5492
# -*- coding: utf-8 -*-
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
if B>A:
  if (A+V*T) >= (B+W*T):
    print('YES')
  else:
    print('NO')
else:
  if (A-V*T) <= (B-W*T):
    print('YES')
  else:
    print('NO')
  

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

using namespace std;

int main (void) {
	int a[3];
	int cnt;
	
	for (cnt = 0; cnt < 3; cnt++){
		cin >> a[cnt];
		}
	
	cout << max(max(a[0], a[1]), a[2]) - min(min(a[0], a[1]), a[2]) << "\n";
	
	return 0;
	}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

/**
 * A Fat Wallet
 * PCK2014 ??????2
 */
public class Main {

	static final int[] coins = new int[]{1, 5, 10, 50, 100, 500};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		StringTokenizer st = new StringTokenizer(br.readLine());

		int sum = 0;
		for (int i = 0; i < coins.length; i++) {
			sum += parseInt(st.nextToken()) * coins[i];
		}
		System.out.println(sum < 1000 ? 0 : 1);
	}
}

Measured memory_bytes: 24376
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        long A[]=new long[N];
        for(int i=0; i<N; i++){
            A[i]=sc.nextInt();
        }
        long res = 0;
        long max = 0;
        for(int i=0; i<N; i++){
            if(A[i]<max){
                res = res + max - A[i];
            }else{
                max = A[i];
            }
            
        }
		System.out.println(res);
	}
}

Measured memory_bytes: 61580
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

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

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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 nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n,x,t; cin >> n >> x >> t;
  cout << (n+x-1)/x * t << endl;
  
  
}

Measured memory_bytes: 3636
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = 1e18;
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; }

int main(){
    ll N; cin >> N;
    vector<int> A(N); REP(i, 0, N) cin >> A[i];

    map<int, int> m;
    ll ans = 0;
    for (int i = N - 1; i >= 0; --i){
        ans += m[A[i] + i];  // Lの値の場所を探していって，もしRが既に登録されている場所であれば1．まだなら0が入るので，L=Rとなる時にカウントしていることになる
        ++m[i - A[i]];  // Rの値となった場所に1という痕跡を残す
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
  int h1, m1, h2, m2, k, x;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  x = (h2*60 + m2) - (h1*60 + m1) -k;
  cout << x << endl;
}

Measured memory_bytes: 3620
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();

    let mut buf: String = String::new();
    stdin.lock().read_line(&mut buf).unwrap();
    stdin.lock().read_line(&mut buf).unwrap();
    let vec: Vec<&str> = buf.split_whitespace().collect(); 

    let n: usize = vec[0].parse().unwrap();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = vec[i+1].parse().unwrap();
    }

    print_sequence(&seq);
    for i in 1..n {
        let key = seq[i];
        let mut j: i32 = (i - 1) as i32;
        while j >= 0 && seq[j as usize] > key {
            seq[(j+1) as usize] = seq[j as usize];
            j = j - 1;
        }
        seq[(j+1) as usize] = key;
        print_sequence(&seq);
    }
}

fn print_sequence(seq: &Vec<i32>) {
    let n = seq.len();

    let mut out: String = String::new();
    out.push_str(&seq[0].to_string());
    for i in 1..n {
        out.push(' ');
        out.push_str(&seq[i].to_string());
    }

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


Measured memory_bytes: 5052
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main()
{
	int n,k;
	cin>>n>>k;
	int x=n*3;
	x+=k;
	cout<<x/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 
ll sum,MIN=INF;
int main() {
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		ll z;
		cin>>z;
		sum+=z;
		if(z%10!=0){
			MIN=min(MIN,z);
		}
	}
	if(sum%10!=0){
		cout <<sum;
		return 0;
	}
	cout <<(MIN==INF? 0:sum-MIN);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int h,a; cin>>h>>a;
	cout<<(h+a-1)/a<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 N,maxi,mid,sa=1e9;

int main(){
    cin>>N;
    int A[N];
    rep(i,N){
        cin>>A[i];
    }
    sort(A,A+N);
    maxi=A[N-1];
    rep(i,N-1){
        if(abs(maxi/2-A[i])<sa){
            mid=A[i];
            sa=abs(maxi/2-A[i]);
        }
        else if(abs(maxi/2+1-A[i])<sa){
            mid=A[i];
            sa=abs(maxi/2+1-A[i]);
        }
    }
    printf("%d %d\n",maxi,mid);
    
}


Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int l=fs.nextInt(), r=fs.nextInt(), d=fs.nextInt();
		int c=0;
		c+=r/d;
		c-=(l-1)/d;
		System.out.println(c);
	}

	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

ll MOD = 1e9 + 7;

int main() {
    ll n; cin >> n;
    ll ans = 1;
    for(int i = 1; i <= n; i++){
        ans = ans * i % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int h,w,ans=0,c[2000][2000],t[2000][2000]={};
  cin>>h>>w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>c[i][j];
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(c[i][j]==0){
	if(i==0 || j==0)
	  t[i][j]=1;
	if(i!=0 && j!=0){
	  t[i][j]=t[i][j-1];
	if(t[i][j]>=t[i-1][j-1])
       t[i][j]=t[i-1][j-1];
    if(t[i][j]>=t[i-1][j])
       t[i][j]=t[i-1][j];
    t[i][j]+=1;
    }
	if(t[i][j]*t[i][j]>ans)
	  ans=t[i][j]*t[i][j];
      }
    }
  }
  cout<<ans<<endl;
      return(0);
}


Measured memory_bytes: 29664
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
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; }

int main() {
    int k,s;
    cin >> k >> s;
    int ans = 0;
    for(int x = 0;x<=k;x++) {
        for(int y = 0;y<=k;y++) {
            int z = s-x-y;
            if(z>=0 && z<=k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	vi a(n); rep(i, n) cin >> a[i];
	map<int, int> cnt;
	rep(i, n) cnt[a[i]]++;
	auto solve = [&](){
		if(cnt.size() == 1 && a[0] == 0) return true;
		if(n % 3 || cnt.size() > 3) return false;
		vi v;
		for(const auto &i : cnt){
			if(i.second % (n / 3)) return false;
			rep(j, i.second / (n / 3)) v.pb(i.first);
		}
		return (v[0] ^ v[1]) == v[2];
	};
	cout << (solve() ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
const int INF=(1<<22);
int dp[1000000];
int d[20];
int main(){
	int n, m;std::cin>>n>>m;
	std::fill(dp, dp+n+1,INF);dp[0]=0;
	for(int i=0;i<m;++i)std::cin>>d[i];
	for(int i=0;i<m;++i)for(int j=d[i];j<=n;++j){
			dp[j]=std::min(dp[j],dp[j-d[i]]+1);
	}
	std::cout<<dp[n]<<std::endl;
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+6;
ll a[maxn];
vector<int> e[maxn];
void dfs(int u,int fa)
{
	a[u]+=a[fa];
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i]; 
		if(v==fa) continue;
		dfs(v,u);
	}
}
int main()
{
    int n,q;cin>>n>>q;
    for(int i=1;i<n;i++)
    {
    	int x,y;cin>>x>>y;
    	e[y].push_back(x);
    	e[x].push_back(y);
	}
	while(q--)
	{
		int x;ll y;cin>>x>>y;
		a[x]+=y;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++) cout<<a[i]<<" ";
	cout<<endl; 
}


Measured memory_bytes: 24320
#include <stdio.h>

int main(){
    int n, k, x, m=0;
    scanf("%d %d", &n, &k);

    for(int i = 0; i<n; i++){
        scanf("%d", &x);
        if(x>(k-x)){
            m+=k-x;
        }else{
            m+=x;
        }
    }
    printf("%d", m*2);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>

int main(int argc, char** argv) {
  std::cout << std::fixed << std::setw(8);
  int N;
  std::cin >> N;
  int k = (N+1)/2;
  double c = k/static_cast<double>(N);
  std::cout << c << '\n';
}


Measured memory_bytes: 256
s = list(map(int, list(input())))

if len(s) == 1:
    print(s[0])
    exit()

m = len(s) - 1

n = 2 ** m

ans = 0
for i in range(n):
    d = list(map(int, list(str(bin(i)))[2:]))
    if len(d) < m:
        d = [0] * (m - len(d)) + d

    temp = s[0]
    for j in range(m):
        if d[j] == 0:
            ans += temp
            temp = s[j+1]
        else:
            temp *= 10
            temp += s[j+1]
    ans += temp
    #print(d, ans)

print(ans)


Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct node {
	unsigned int key;
	struct node *next;
	struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key) {
	/* your code */
	NodePointer a = nil->next;
	while(a != nil && a->key != key){
		a=a->next;
	}
	
	return a;
}

void init() {
	nil = malloc(sizeof(struct node));
	nil->next = nil;
	nil->prev = nil;
}

void printList() {
	NodePointer cur = nil->next;
	int isf = 1;
	while(1) {
		if ( cur == nil ) break;
		if ( isf == 0)  printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
		isf = 0;
	}
	printf("\n");
}

void deleteNode(NodePointer t) {
	/* your code */

	if(t==nil){
		return;
	}
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst() {
	NodePointer t = nil->next;
	if ( t == nil ) return;
	deleteNode(t);
}

void deleteLast() {
	/* your code */
	deleteNode(nil->prev);
}

void delete(int key) {
	/* your code */

	deleteNode(listSearch(key));
}


void insert(int key) {
	NodePointer x;
	x = malloc(sizeof(struct node));
	x->key = key;
	
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
	/*	 your code	*/

}

int main() {
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for ( i = 0; i < n; i++ ) {
		scanf("%s%d", com, &key);
		if ( com[0] == 'i' ) {
			insert(key);
			np++;
			size++;
		}
		else if ( com[0] == 'd' ) {
			if (strlen(com) > 6) {
				if ( com[6] == 'F' ) deleteFirst();
				else if ( com[6] == 'L' ) deleteLast();
			} else {
				delete(key);
				nd++;
			}
			size--;
		}
	}

	printList();
	return 0;
}


Measured memory_bytes: 32996
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main(void) {
	
	int x, y;
	bool yes = false;
	scanf("%d %d", &x, &y);
	for (int i = 0; i <= x; i++) {
		if ((2 * i + 4 * (x - i)) == y) {
			yes = true;
		}
	}
	if (yes) printf("Yes");
	else printf("No");
	

	
	return 0;
}

Measured memory_bytes: 3836
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

int main()
{

    double s, l, h, sdA, sdB, sdC, agC;
    scanf("%lf %lf %lf", &sdA, &sdB, &agC);
    agC = agC * M_PI / 180;
    s = sdA * sdB * sin(agC) / 2;
    printf("%lf\n", s);
    sdC = sqrt(sdA * sdA + sdB * sdB - 2 * sdA * sdB * cos(agC));
    l = sdA + sdB + sdC;
    printf("%lf\n", l);
    h = s * 2 / sdA;
    printf("%lf\n", h);
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main() {
	string A, B; cin >> A >> B;
	if(A.size() > B.size()) cout << "GREATER" << endl;
	else if(A.size() < B.size()) cout << "LESS" << endl;
	else {
		for (int i = 0; i < A.size(); i++)
		{
			if(A[i] - '0' > B[i] - '0') {
				cout << "GREATER" << endl;
				return 0;
			}
			else if(A[i] - '0' < B[i] - '0') {
				cout << "LESS" << endl;
				return 0;
			}
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}


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

int main(){
	int n;
	cin>>n;
	int g=0;
	int k=0;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		if(a%2==0){
			g++;
		}else{
			k++;
		}
	}
	
	if(k%2==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	
	return 0;
}

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

using namespace std;  

int main(){  
 int K;
  string S;
	cin >> K;
    cin >> S;
  if ( K >= S.size()) {
    cout << S << endl;
    return 0;
  }
  else {
	for (int i = 0; i < K; i++){
      cout << S.at(i);
    }
    cout << "..." << endl;
    return 0;
  }
  
}  

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final char[] S = sc.next().toCharArray();
			final char[] T = sc.next().toCharArray();
			
			long[][] DP = new long[S.length + 1][T.length + 1];
			int[][] prev_i = new int[S.length + 1][T.length + 1];
			int[][] prev_j = new int[S.length + 1][T.length + 1];
			
			for(int i = 1; i <= S.length; i++) {
				for(int j = 1; j <= T.length; j++) {
					if(S[i - 1] == T[j - 1]) {
						DP[i][j] = DP[i - 1][j - 1] + 1;
						prev_i[i][j] = i - 1;
						prev_j[i][j] = j - 1;
					}else {
						DP[i][j] = Math.max(DP[i][j - 1], DP[i - 1][j]);
						
						if(DP[i][j - 1] > DP[i - 1][j]) {
							prev_i[i][j] = i;
							prev_j[i][j] = j - 1;
						}else {
							prev_i[i][j] = i - 1;
							prev_j[i][j] = j;
						}
					}
				}
			}
			
			LinkedList<Character> answer = new LinkedList<Character>();
			{
				int i = S.length, j = T.length;
				while(i > 0 && j > 0) {
					if(prev_i[i][j] == i || prev_j[i][j] == j) {
						final int old_i = i, old_j = j;
						i = prev_i[old_i][old_j];
						j = prev_j[old_i][old_j];
					}else {
						answer.addFirst(S[i - 1]);
						final int old_i = i, old_j = j;
						i = prev_i[old_i][old_j];
						j = prev_j[old_i][old_j];
					}
				}
			}
			
			StringBuilder sb = new StringBuilder();
			for(final char ch : answer) { sb.append(ch); }
			System.out.println(sb.toString());
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 180340
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s;
		s = sc.nextLine();
		sc.close();
		String ans = "";
		
		int length = s.length() - 2;
		ans += s.charAt(0);
		ans += Integer.toString(length);
		ans += s.charAt(length + 1);
		System.out.println(ans);
	}

}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

int getsum(const vvi& sums,int t,int b,int l,int r)
{
	if(l>=r || t>=b) return 0;
	return sums[b][r]-sums[t][r]-sums[b][l]+sums[t][l];
}

void chmax(int& a,int b)
{
	a=max(a,b);
}

int main()
{
	for(int h,w;cin>>h>>w && h|w;){
		vs grid(h);
		rep(i,h) cin>>grid[i];

		int ci=-1,cj=-1;
		rep(i,h) rep(j,w) if(grid[i][j]=='E') ci=i,cj=j;

		vvi sums(h+1,vi(w+1));
		rep(i,h) rep(j,w)
			sums[i+1][j+1]=(grid[i][j]=='o')+sums[i+1][j]+sums[i][j+1]-sums[i][j];

		int T=h-1-ci,B=ci,L=w-1-cj,R=cj;

		int dp[T+1][B+1][L+1][R+1]={};
		rep(t,T+1) rep(b,B+1) rep(l,L+1) rep(r,R+1){
			if(t!=T && ci+t+1<h-b)
				chmax(dp[t+1][b][l][r],dp[t][b][l][r]+getsum(sums,ci+(t+1),ci+(t+1)+1,max(cj-r,l),min(cj+l+1,w-r)));
			if(b!=B && t<=ci-(b+1))
				chmax(dp[t][b+1][l][r],dp[t][b][l][r]+getsum(sums,ci-(b+1),ci-(b+1)+1,max(cj-r,l),min(cj+l+1,w-r)));
			if(l!=L && cj+l+1<w-r)
				chmax(dp[t][b][l+1][r],dp[t][b][l][r]+getsum(sums,max(ci-b,t),min(ci+t+1,h-b),cj+(l+1),cj+(l+1)+1));
			if(r!=R && l<=cj-(r+1))
				chmax(dp[t][b][l][r+1],dp[t][b][l][r]+getsum(sums,max(ci-b,t),min(ci+t+1,h-b),cj-(r+1),cj-(r+1)+1));
		}

		int res=0;
		rep(t,T+1) rep(b,B+1) rep(l,L+1) rep(r,R+1) chmax(res,dp[t][b][l][r]);
		cout<<res<<endl;
	}
}


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

const ll INF = 1LL << 60;

ll N, K;
vector<ll> A;

int main() {
    cin >> N >> K;
    A.resize(N);
    rep(i, N) cin >> A[i];

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

    ll left = -INF, right = INF;
    while (right - left > 1) {
        ll x = (left + right) / 2;

        bool ok = [&] {
            ll total = 0;
            rep(i, N) {
                if (A[i] < 0) {
                    ll l = -1, r = N;
                    while (r - l > 1) {
                        ll c = (r + l) / 2;
                        if (A[c] * A[i] < x) {
                            r = c;
                        } else {
                            l = c;
                        }
                    }

                    total += (N - r);
                } else {
                    ll l = -1, r = N;
                    while (r - l > 1) {
                        ll c = (r + l) / 2;
                        if (A[c] * A[i] < x) {
                            l = c;
                        } else {
                            r = c;
                        }    
                    }
                    
                    // total += (l + 1);
                    total += r;
                }

                if (A[i] * A[i] < x) total--;
            }

            total /= 2;
            return total < K;
        }();


        if (ok) {
            left = x;
        } else {
            right = x;
        }
    }
    // cout << INF << " " << -INF << endl;

    cout << left << endl;
}

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

int main() {
    string S, T;
    cin >> S >> T;
    
    int ss = S.size();
    
    //cout << T.substr(0,ss) << ss << endl;
    if(T.substr(0,ss) == S && T.size()-1 == ss)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
	int i,j,n,g[6]={0,0,0,0,0,0};
	double h;
	cin >> n;
	for (i=0;i<n;i++) {
		cin >> h;
		if (h<165) g[0]++; else if (h>=185) g[5]++; else g[(int)((h-165)/5)+1]++;
	}
	for (i=0;i<6;i++) {
		cout << i+1 << ':';
		if (g[i]>0) for (j=0;j<g[i];j++) cout << '*';
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
const double p = 3.14159265;

int main(){
    double r;
    cin >> r;
    double ans = 2.0*p*r;
    
    
    
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 3764
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;

int main()
{
    string o;
    string e;
    in e>>o;
    rep(i,e.size())
    {
        cout<<e[i];
        if(i<o.size())cout<<o[i];
    }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <assert.h>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 2005
#define mod 998244353
#define INF 0x3f3f3f3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int main() {
	int a, p;
	cin >> a >> p;
	p = p + 3 * a;
	p /= 2;
	cout << p << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define ll long long
int main(){
    int n;
    scanf("%d",&n);
    ll a[n + 1];
    ll max = n;
    for(int i = 1; i <= n; i++){
        scanf("%lld",&a[i]);
        if(a[i] > n - 1)
            a[i] = 0;
    }
    ll ans = 0;
    ll b[n + 1], c[n + 1];
    for(int i = 1; i <= n; i++){
        b[i] = i - a[i];
        c[i] = i + a[i];
        if(a[i] == 0){
            b[i] = -1;
            c[i] = -1;
        }
    }
    int d[2 * n + 1];
    for(int i = 0; i < 2 * n; i++)
        d[i] = 0;
    for(int i = 1; i <= n; i++){
        if(c[i] >= 0)
            d[c[i]] ++;
    }
    for(int i = 1; i <= n; i++){
        if(b[i] >= 0){
            ans += d[b[i]];
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
    string S,T;
    cin >> S;
    cin >> T;

    bool res = true;
    for(int i=0; i<T.size()-1; i++){
        if(S[i] != T[i]){
            res = false;
        }
    }
    if(res){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int64_t N, A, B;
V<int64_t> H;

int solvekek() {
	set<pair<int64_t, int>> S;
	for (int i = 0; i < N; ++i) {
		S.emplace(H[i], i);
	}
	int64_t steps = 0;
	while (!S.empty()) {
		++steps;
		auto curr = *S.rbegin();
		S.erase(curr);
		// cout << curr.first << " " << curr.second << endl;
		// for (auto e : S) {
		// 	cout << " " << e.first << " " << e.second << endl;
		// }
		curr.first -= A;
		set<pair<int64_t, int>> next;
		for (pair<int64_t, int> kek : S) {
			next.emplace(kek.first-B, kek.second);
		}
		S = next;
		S.emplace(curr.first, curr.second);
		while (!S.empty() && S.begin()->first <= 0) {
			S.erase(S.begin());
		}
	}
	return steps;
}


int solve() {
	int lo = 0, hi = 1e9+10;
	while (lo < hi) {
		int64_t mid = (lo+hi)/2;
		int64_t cnt = 0;
		REP(i, N) {
			int lo2 = 0, hi2 = mid+10;
			while (lo2 < hi2) {
				int mid2 = (lo2+hi2)/2;
				int64_t kek = H[i]-(mid-mid2)*B-mid2*A;
				if (kek <= 0) {
					hi2 = mid2;
				} else {
					lo2 = mid2+1;
				}
			}
			cnt += lo2;
		}
		// cout << mid << " " << cnt << endl;
		if (cnt <= mid) {
			hi = mid;
		} else {
			lo = mid+1;
		}
	}
	return lo;
}

void test() {
	default_random_engine re;
	for (int tc = 0; tc < 1000; ++tc) {
		N = re()%5+1;
		A = re()%1000000000+1;
		B = re()%A+1;
		H = V<int64_t>(N);
		for (int64_t& e : H) {
			e = re()%1000000000+1;
		}
		assert(solvekek() == solve());
	}
}

int main() {
	// test();
	// return 0;
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> N >> A >> B;
	H = V<int64_t>(N);
	READALL(H);

	// cout << solvekek() << endl;
	cout << solve() << endl;
}

Measured memory_bytes: 1024
#include <stdlib.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    return *(long long*)b - *(long long*)a ;
}
int main()
{
    long long n,h=0,i,w=0,flag=0,a[100001];
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    qsort(a,n,sizeof(long long),compare);
    for(i=0;i<n-1;i++){
        //printf("a[%lld]=%lld\n",i,a[i]);
        if(a[i]==a[i+1]&&flag==0){
            h=a[i];
            i++;
            flag=1;
        }else if(a[i]==a[i+1]){
            w=a[i];
            break;
        }
        
    }
    printf("%lld",h*w);
    return 0;
}


Measured memory_bytes: 1788
# https://atcoder.jp/contests/abc154/tasks/abc154_d
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n, k = input_int_list()
    P = [0] + input_int_list()
    expected_sum = [0] * (n + 1)
    # pre-process
    for i in range(1, n + 1):
        exp = (P[i] + 1) / 2
        expected_sum[i] = expected_sum[i - 1] + exp
    ans = 0
    # query from cusum
    for i in range(k, n + 1):
        ans = max(ans, expected_sum[i] - expected_sum[i - k])
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 101032
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> PP;
const int mod = 1000000007;

int D, W, field[10][10];

int calc(int a, int b, int c, int d)
{
    int MIN = INF, MAX = -INF;
    Rep(i, b, d + 1) MIN = min(MIN, field[a][i]);
    Rep(i, b, d + 1) MIN = min(MIN, field[c][i]);
    Rep(i, a, c + 1) MIN = min(MIN, field[i][b]);
    Rep(i, a, c + 1) MIN = min(MIN, field[i][d]);
    Rep(i, a + 1, c) Rep(j, b + 1, d) MAX = max(MAX, field[i][j]);
    if (MAX >= MIN)
        return 0;
    int res = 0;
    Rep(i, a + 1, c) Rep(j, b + 1, d) res += MIN - field[i][j];
    return res;
}

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

    while (1)
    {
        cin >> D >> W;
        if (D == 0)
            break;
        rep(i, D) rep(j, W) cin >> field[i][j];
        int ans = 0;
        rep(i, D) rep(j, W) Rep(k, i + 1, D) Rep(l, j + 1, W) ans = max(ans, calc(i, j, k, l));
        cout << ans << endl;
    }
}


Measured memory_bytes: 3136
#include <cstdio>
#include <algorithm>

using namespace std;

int N;
int R;
int L;

pair<int, int> seg[100000 * 4];

void update(int k, int a, int b, int p, int x) {
  if (p < a || b <= p)
    return;
  if (b - a == 1) {
    int tmp = seg[k].first;
    seg[k] = make_pair(tmp + x, -p);
  } else {
    update(2*k+1, a, (a+b)/2, p, x);
    update(2*k+2, (a+b)/2, b, p, x);
    seg[k] = max(seg[2*k+1], seg[2*k+2]);
  }
}

const int oo = 1<<30;
pair<int, int> query(int k, int a, int b, int l, int r) {
  if (r <= a || b <= l)
    return make_pair(-oo, 0);
  if (l <= a && b <= r)
    return seg[k];
  pair<int, int> r1 = query(2*k+1, a, (a+b)/2, l, r);
  pair<int, int> r2 = query(2*k+2, (a+b)/2, b, l, r);
  return max(r1, r2);
}

int cnt[100000];

int main(int argc, char *argv[])
{
  int pre_t = 0;
  scanf(" %d %d %d", &N, &R, &L);
  for (int i = 0; i < R; i++) {
    int d, t, x;
    scanf(" %d %d %d", &d, &t, &x);
    auto v = query(0, 0, N, 0, N);
    cnt[-v.second] += t - pre_t;
    pre_t = t;
    update(0, 0, N, d-1, x);
  }
  auto v = query(0, 0, N, 0, N);  
  cnt[-v.second] += L - pre_t;

  int r = 0;
  for (int i = 1; i < N; i++) {
    if (cnt[i] > cnt[r])
      r = i;
  }

  printf("%d\n", r+1);
  
  return 0;
}

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

int main() {
	int N, M;
	cin >> N >> M;
	int L, R, Lmax = 0, Rmin = N + 1;
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		Lmax = max(L, Lmax);
		Rmin = min(R, Rmin);
	}
	if (Rmin < Lmax) {
		cout << 0 << endl;
		return 0;
	}
	cout << Rmin - Lmax + 1 << endl;
	return 0;
}

Measured memory_bytes: 256