akhauriyash/Code-Regression huggingface dataset:
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#define WOULD
#define YOU
#define PLEASE
#define ACCEPT
#define MY
#define SUBMISSION
/* I REALLY HOPE MY WISH REACH YOU , ATCODER'S ONLINE JUDGE */
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

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; }
const long long INF = 100100100100;
const long long MOD = 998244353;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

int main() {
    int N;cin >> N;
    vector<long long> retu(N);
    for(int i = 0;i<N;i++) cin >> retu.at(i);
    sort(retu.begin(),retu.end());
    reverse(retu.begin(),retu.end());
    long long standard = retu.at(0);
    long long diff = INF;
    long long nearMedian;
    for(int i = 1;i<N;i++){
        long long nowDiff = abs(standard/2-(standard - retu.at(i)));
        if(nowDiff > standard/2) nowDiff = standard-nowDiff;
        if(diff > nowDiff){
            diff = nowDiff;
            nearMedian = retu.at(i);
        }
    }

    cout << standard << " " << nearMedian << endl;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		

		Scanner sc = new Scanner(System.in);
		String[] days={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
		while(sc.hasNextInt()){
			int month=sc.nextInt();
			int day=sc.nextInt();
			int a=modd(month);
			int b=a+day;
			if(month==0){
				break;
			}
			if((b-1)%7==0){
				System.out.println(days[0]);
		}else if((b-1)%7==1){
			System.out.println(days[1]);
		}else if((b-1)%7==2){
			System.out.println(days[2]);
		}else if((b-1)%7==3){
			System.out.println(days[3]);
		}else if((b-1)%7==4){
			System.out.println(days[4]);
		}else if((b-1)%7==5){
			System.out.println(days[5]);
		}else if((b-1)%7==6){
			System.out.println(days[6]);
		}
	}

	}
	public static int modd(int month){
		int[] months={31,29,31,30,31,30,31,31,30,31,30,31};
		int a=0;
		for(int i=0; i<=month-2; i++){
			a+=months[i];
		}

		return a;
	}
















}

Measured memory_bytes: 26080
#define _USE_MATH_DEFINES
#include <iostream> 
#include <string>
#include <map>
using namespace std; 
map<pair<char,int>,int>m;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		char tmp;
		int hoge;
		cin>>tmp>>hoge;
		m[make_pair(tmp,hoge)]=1;
	}	
	for(int i=1;i<=13;i++){
		if(m[make_pair('S',i)]==0){
			cout<<"S "<<i<<endl;
		}
	}
	for(int i=1;i<=13;i++){
		if(m[make_pair('H',i)]==0){
			cout<<"H "<<i<<endl;
		}
	}
	for(int i=1;i<=13;i++){
		if(m[make_pair('C',i)]==0){
			cout<<"C "<<i<<endl;
		}
	}
	for(int i=1;i<=13;i++){
		if(m[make_pair('D',i)]==0){
			cout<<"D "<<i<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3076
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main(){
    int a;
    int b;
    int ans_add;
    int ans_sub;
    int ans_mul;
    int ans;

    cin >> a >> b;
    ans_add=a+b;
    ans_sub=a-b;
    ans_mul=a*b;
    if(ans_add>ans_sub){
        ans=ans_add;
    }else{
        ans=ans_sub;
    }
    if(ans_mul>ans){
        ans=ans_mul;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter as c
d=c()
h,w=map(int,input().split())
for _ in range(h):
  d+=c(input())

def solve():
  global h,w
  if h%2==0 and w%2==0:
    return False if any(map(lambda x:x%4,d.values())) else True

  e=c()
  for i in d.values():e[i%4]+=1

  if h%2 and w%2:
    if e[3] or e[1]!=1 or e[2]>(h-1)/2+(w-1)/2:return False
    return True

  if w%2:h,w=w,h
  if (e[1] or e[3]) or e[2]>w/2:return False
  return True

print("Yes" if solve() else "No")

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

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

    priority_queue<int, vector<int>, greater<int>> input; /* 昇順 */
    priority_queue<int> diff; /* 降順 */
    for (int i = 0; i < m; i++) {
	int tmp;
	cin >> tmp;
	input.push(tmp);
    }

    int head = input.top();
    input.pop();
    diff.push(0); // dummy
    while (!input.empty()) {
	diff.push(abs(head - input.top()));
	head = input.top();
	input.pop();
    }

    for (int i = 0; i < n - 1; i++) {
	if (!diff.empty())
	    diff.pop();
    }
    
    int res = 0;
    while (!diff.empty()) {
	res += diff.top();
	diff.pop();
    }
	
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 1400
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s | x < 1200  = "ABC"
        | otherwise = "ARC"
  where x = read s :: Int

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define per(i,a,b) for(int i =(b)-1;i>=(a);--i)
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
typedef vector<int> vi;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 10;
vi edge[maxn];
int h[maxn];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int n,m;
	cin >> n >> m;
	rep(i,1,n+1)cin >> h[i];
	rep(i,0,m){
		int u,v;
		cin >> u >> v;
		edge[u].pb(v);
		edge[v].pb(u);
	}
	int ans = 0;
	rep(i,1,n+1){
		int fuck = 1;
		for(auto it:edge[i]){
			if(h[it] >= h[i]){
				fuck = 0;
				break;
			}
		}
		ans += fuck;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 53716
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n,x = LI()
    a = [I() for _ in range(n)]
    x -= sum(a)

    return n + x // min(a)



print(main())



Measured memory_bytes: 5456
import java.util.*;
import java.io.*;
import static java.lang.System.*;

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;
  private boolean hasNextByte() {
      if (ptr < buflen) {
          return true;
      }else{
          ptr = 0;
          try {
              buflen = in.read(buffer);
          } catch (IOException e) {
              e.printStackTrace();
          }
          if (buflen <= 0) {
              return false;
          }
      }
      return true;
  }
  private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
  private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
  public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
  public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while(isPrintableChar(b)) {
          sb.appendCodePoint(b);
          b = readByte();
      }
      return sb.toString();
  }
  public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
          minus = true;
          b = readByte();
      }
      if (b < '0' || '9' < b) {
          throw new NumberFormatException();
      }
      while(true){
          if ('0' <= b && b <= '9') {
              n *= 10;
              n += b - '0';
          }else if(b == -1 || !isPrintableChar(b)){
              return minus ? -n : n;
          }else{
              throw new NumberFormatException();
          }
          b = readByte();
      }
  }
  public int nextInt() {
      long nl = nextLong();
      if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      return (int) nl;
  }
  public double nextDouble() { return Double.parseDouble(next());}
}

class Main {
  public static final int MOD = 1000000007;
  public static final int INF = 1000000000;
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long A = sc.nextLong();
    long B = sc.nextLong();
    int C = sc.nextInt();
    int D = sc.nextInt();
    long lcm = (long)C * D / gcd(C, D);
    long countB = B - (B / C + B / D - B / lcm);
    long countA = (A-1) - ( (A-1) / C + (A-1) / D - (A-1) / lcm);
    long ans = countB - countA;
    out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

const int N = 2e5 + 5;
typedef long long LL;

int n, a[N], to[N][64], now;
LL k;

int main() {
	cin>>n>>k;
	for(int i = 1; i <= n; i++)
		cin>>a[i], to[i][0] = a[i];
	for(int k = 1; k <= 62; k++)
		for(int i = 1; i <= n; i++)
			to[i][k] = to[to[i][k - 1]][k - 1];
	now = 1;
	for(int i = 62; i >= 0; i--) {
		if(k >= (1ll<<i)) {
			k -= 1ll<<i;
			now = to[now][i];
		}
	}
	cout<<now<<endl;
	return 0;
}

Measured memory_bytes: 54416
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for (int i = 0 ; i < m ; i++) {
            b[i] = sc.nextInt();
        }
        int[][] a = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            for (int j = 0 ; j < m ; j++) {
                a[i][j] = sc.nextInt();
            }
        }
        int count = 0;
        for (int i = 0 ; i < n ; i++) {
            int sum = 0;
            for (int j = 0 ; j < m ; j++) {
                sum += b[j] * a[i][j];
            }
            if (sum + c > 0) count++;
        }
        System.out.println(count);
    }

}

Measured memory_bytes: 22100
seisu = input()
first = ""
state = False
counter = 0
for s in seisu:
    if not state:
        first = s
        state = True
        continue
    if first == s:
        counter += 1
    else:
        break

if counter < 2:
    counter = 0
    hikaku = ""
    num = 0
    for s in seisu:
        if num != 0:
            if num == 1:
                hikaku = s
            else:
                if s == hikaku:
                    counter += 1
        num += 1

        
if counter >= 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
n = gets.to_i
a = gets.split.map(&:to_i)
low_lim = Array.new(n + 1, nil)
up_lim = Array.new(n + 1, nil)
low_lim[n] = a[n]
up_lim[n] = a[n]
(n - 1).downto(0) do |i|
  low_lim[i] = (low_lim[i + 1] + 1) / 2 + a[i]
  up_lim[i] = up_lim[i + 1] + a[i]
end
b = Array.new(n + 1, nil)
b[0] = 1
flag = true
for i in 1..n do
  tmp = (b[i - 1] - a[i - 1]) * 2
  if tmp < low_lim[i]
    flag = false
    break
  else
    b[i] = [tmp, up_lim[i]].min
  end
end
if n > 0
  puts flag ? b.inject(:+) : -1
else
  puts (a[0] == 1) ? 1 : -1
end


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



int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n, k; cin >> n >> k;
  vector<LL> pre(n + 1), A(n), all;
  for (int i = 0; i < n; ++i) cin >> A[i], pre[i + 1] = pre[i] + A[i];

  for (int i = 0; i < n; ++i) for (int j = i + 1; j <= n; ++j) 
    all.push_back(pre[j] - pre[i]);
  sort(all.begin(), all.end());
  assert(all.size() == n * (n + 1) / 2);
  LL ans = 0;
  for (LL i = 60; i >= 0; --i) {
    vector<LL> refresh;
    for (auto a: all) if ((a>>i)&1) refresh.push_back(a);
    if (refresh.size() >= k) {
      all = refresh;
      ans |= 1ll << i;
    }
  }
  cout << ans << '\n';
}



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

map<int, int> freqmap;
vector<int> most_freqs;

int main() {
    int n;
    while (cin >> n) {
        freqmap[n]++;
    }

    int freq = 0;
    for (map<int, int>::iterator i = freqmap.begin(); i != freqmap.end(); i++) {
        freq = freq > (*i).second ? freq : (*i).second;
    }

    for (map<int, int>::iterator i = freqmap.begin(); i != freqmap.end(); i++) {
        if ( (*i).second == freq ) {
            most_freqs.push_back( (*i).first );
        }
    }

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

    for (vector<int>::iterator i = most_freqs.begin(); i != most_freqs.end(); i++) {
        cout << (*i) << endl;
    }

    return 0;
}

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

using namespace std;

vector<int> g[200001];
int visited[200001];

int main() {
    int N, M;
    cin>>N>>M;
    for (int i=1;i<=N;i++) {
        g[i].clear();
        visited[i] = -1;
    }
    int a, b;
    for (int i=0;i<M;i++) {
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    queue<int> Q;
    Q.push(1);
    visited[1] = 0;
    bool reachable = false;
    while (!Q.empty()) {
        int curr = Q.front();
        Q.pop();
        if (visited[curr] > 1) break;
        for (int i=0;i<g[curr].size();i++) {
            int peer = g[curr][i];
            if (peer == N) {
                reachable = true;
                break;
            }
            if (visited[peer] == -1) {
                Q.push(peer);
                visited[peer] = visited[curr] + 1;
            }
        }
        if (reachable) break;
    }

    if (reachable) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;

    return 0;
}

Measured memory_bytes: 13168
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

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

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, ans; cin >> x;
    ans = (x / 500LL) * 1000LL + ((x % 500LL) / 5LL) * 5LL;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int N = (int)1e5 + 3;

int n, a[N];
bool git = true;

int main() {
  init_ios();
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    if (i == 1) {
      --a[i];
      continue;
    }
    if (a[i] > a[i-1]) {
      --a[i];
      continue;
    }
    if (a[i] < a[i-1])
      git = false;
  }
  if (git)
    cout<<"Yes\n";
  else
    cout<<"No\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;

int main(){
    int n,l; cin>>n>>l;
    vector<string> s(n);
    rep(0,i,n) cin>>s[i];
    sort(s.begin(),s.end());
    rep(0,i,n) cout << s[i];
    cout << endl;
}

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

int main()
{
    int a[5],ans = 0;
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+3+1);
    ans = ans*10 + a[3];
    ans = ans*10 + a[2];
    ans = ans + a[1];
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<=(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<si> vsi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<int> qi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 文字変換　
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned Euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return Euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int digit_sum(int n) {
  int sum=n%10;
  while(n!=0) {
    n/=10;
    sum+=n%10;
  }
  return sum;
}

vpll PrimeFactorization(ll n) {
  vpll 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(pll(i,ex));
  }
  if(n!=1) res.push_back(pll(n,1));
  return res;
}

int main() {
  int x,y,z;
  cin >> x >> y >> z;
  int ans=(x-z)/(y+z);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3572
package main

import (
	"fmt"
	"math"
)

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

	var min float64 = 1000000
	for i := 0; i < n; i++ {
		var c1, t1 int
		fmt.Scan(&c1, &t1)

		if t1 <= t {
			min = math.Min(float64(min), float64(c1))
		}
	}
	if min == 1000000 {
		fmt.Println("TLE")
		return
	}
	fmt.Println(min)
}


Measured memory_bytes: 512
#include <iostream>
#include<string>
#include<vector>
#include<stdio.h>

using namespace std;


int main()
{
	
	string str;
	string str1, str2;
	int a;
	cin >> a;

	cin >> str;

	int length = str.length();
	
	if (length % 2 == 1) {
		cout << "No" << endl;
		return 0;
	}

	str1 = str.substr(0, length / 2);
	str2 = str1 + str1;
	
	if (str2 == str) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}





	return 0;

}



Measured memory_bytes: 256
#include<stdio.h>

#define N 2000001

int n;
int A[N],B[N];

void CountingSort(int* A,int* B,int k){
  int i,j;
  int C[k];
  for(i=0;i<=k;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]=C[A[j]]+1;
  }
  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }
}


main(){
  int i,max=0;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(max<A[i])max=A[i];
  }
  CountingSort(A,B,max);
  for(i=1;i<=n-1;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[n]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 16264
import Data.List
import qualified Data.Set as S
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B

snub = S.toList . S.fromList

readInt = maybe undefined fst . B.readInt

untilFix f x = let x1 = f x in if x1 == x then x else untilFix f x1

kruskal n = kruskalDP n initial 0 0

kruskalDP _ _ acc _ [] = acc
kruskalDP n uf acc x ((d,(a,b)):abd)
  | x == n - 1 = acc
  | same uf a b = kruskalDP n uf acc x abd
  | otherwise = kruskalDP n (merge uf a b) (acc + d) (x + 1) abd

main = do
  _ <- getLine
  xys <- map ((\[x,y]->(x+1,y+1)) . map readInt . B.words) . B.lines <$> B.getContents
  let xyis = zip (snub xys) [1 ..]
  let n = length xyis
  let xysx = xyis
  let xysy = sortOn (snd.fst) xyis
  print (built n xysx xysy)

built n xysx xysy = kruskal n edge
  where
    edge = sort (edgex ++ edgey)
    edgex = zipWith (\((xi,yi),i) ((xj,yj),j) -> (min (abs (xj-xi)) (abs (yj-yi)), (i,j))) xysx (tail xysx)
    edgey = zipWith (\((xi,yi),i) ((xj,yj),j) -> (min (abs (yj-yi)) (abs (xj-xi)), (i,j))) xysy (tail xysy)

data UnionFind = UnionFind {tree :: M.IntMap Point, rk :: M.IntMap Rank}
type Point = Int
type Rank = Int

initial :: UnionFind
initial = UnionFind (M.singleton 0 0) M.empty

(!?) :: UnionFind -> Point -> Point
(!?) uf p = M.findWithDefault 0 p (tree uf)

rep :: UnionFind -> Point -> Point
rep uf = untilFix (uf !?)

rank :: UnionFind -> Point -> Rank
rank uf = (rk uf M.!)

isolate :: UnionFind -> Point -> Bool
isolate uf p = rep uf p == 0

merge :: UnionFind -> Point -> Point -> UnionFind
merge uf p1 p2
  | i1 && i2 = UnionFind (M.insert p2 p1 (M.insert p1 p1 (tree uf))) (M.insert p1 2 (rk uf))
  | i1 = UnionFind (M.insert p1 rp2 (tree uf)) (M.insert rp2 (rk2 + 1) (rk uf))
  | i2 = UnionFind (M.insert p2 rp1 (tree uf)) (M.insert rp1 (rk1 + 1) (rk uf))
  | rp1 /= rp2 && rk1 > rk2 = UnionFind (M.insert p2 rp1 (M.insert rp2 rp1 (tree uf))) (M.insert rp1 (rk1 + rk2) (rk uf))
  | rp1 /= rp2 = UnionFind (M.insert p1 rp2 (M.insert rp1 rp2 (tree uf))) (M.insert rp2 (rk1 + rk2) (rk uf))
  | otherwise = uf
  where
    i1 = isolate uf p1
    i2 = isolate uf p2
    rk1 = rank uf rp1
    rk2 = rank uf rp2
    rp1 = rep uf p1
    rp2 = rep uf p2

same :: UnionFind -> Point -> Point -> Bool
same uf p1 p2
  | p1 == p2 = True
  | otherwise = not (isolate uf p1) && (rep uf p1 == rep uf p2)


Measured memory_bytes: 92540
def main():
    cnt = 0
    n = int(input())
    numlist = [int(x) for x in input().split()]
    while True:
        temp=0
        for i in range(n):
            if numlist[i]%2 == 0:
                temp+=1
                numlist[i]=numlist[i]/2
        if temp==n:
            cnt+=1
        else:
            break
    print(cnt)

if __name__=='__main__':
    main()

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

int main(){
    int N, l, r;
    cin >> N;
    int num = 0;
    for (size_t i = 0; i < N; ++i){
        cin >> l >> r;
        num += r - l + 1;
    }

    cout << num << endl;

    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

struct CumulativeSum2D {
    data: Vec<Vec<i64>>,
}

impl CumulativeSum2D {
    fn new(w: usize, h: usize) -> CumulativeSum2D {
        CumulativeSum2D {
            data: vec![vec![0; w + 1]; h + 1],
        }
    }

    fn add(&mut self, mut x: usize, mut y: usize, z: i64) {
        x += 1;
        y += 1;
        if x >= self.data[0].len() || y >= self.data.len() {
            return;
        }
        self.data[y][x] += z;
    }

    fn build(&mut self) {
        for i in 1..self.data.len() {
            for j in 1..self.data[i].len() {
                self.data[i][j] +=
                    self.data[i][j - 1] + self.data[i - 1][j] - self.data[i - 1][j - 1];
            }
        }
    }

    // sum of [sx, gx), [sy, gy)
    fn query(&self, sx: usize, sy: usize, gx: usize, gy: usize) -> i64 {
        self.data[gy][gx] - self.data[gy][sx] - self.data[sy][gx] + self.data[sy][sx]
    }
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w, q) = (v[0], v[1], v[2]);
    let mut s = vec![vec![]; h];
    for i in 0..h {
        s[i] = read::<String>()
            .chars()
            .map(|x| x.to_digit(10).unwrap() as i64)
            .collect::<Vec<_>>();
    }
    let mut cum2d = CumulativeSum2D::new(w, h);
    for y in 0..h {
        for x in 0..w {
            cum2d.add(x, y, s[y][x]);
        }
    }
    cum2d.build();

    let mut cum2d_column = CumulativeSum2D::new(w - 1, h);
    for y in 0..h {
        for x in 0..w - 1 {
            if s[y][x] == 1 && s[y][x + 1] == 1 {
                cum2d_column.add(x, y, 1);
            }
        }
    }
    cum2d_column.build();

    let mut cum2d_row = CumulativeSum2D::new(w, h - 1);
    for y in 0..h - 1 {
        for x in 0..w {
            if s[y][x] == 1 && s[y + 1][x] == 1 {
                cum2d_row.add(x, y, s[y][x]);
            }
        }
    }
    cum2d_row.build();

    for _ in 0..q {
        let v = read_vec::<usize>();
        let (y1, x1, y2, x2) = (v[0] - 1, v[1] - 1, v[2] - 1, v[3] - 1);
        let apexes = cum2d.query(x1, y1, x2 + 1, y2 + 1);
        let columns = cum2d_column.query(x1, y1, x2, y2 + 1);
        let rows = cum2d_row.query(x1, y1, x2 + 1, y2);
        println!("{}", apexes - columns - rows);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

struct S {
	int x, y, mask;
	ll hash() {
		return (ll)x + 15 * (ll)y + (ll)mask * (20 * 20);
	}
};

int b[19][15];

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

bool in(int x, int y) {
	return 0 <= x && x < 15 && 0 <= y && y < 19;
}

map<ll, int> dp;

int main() {
	int B = 0;
	int sx = -1, sy = -1;

	memset(b, -1, sizeof b);
	for(int i = 0; i < 19; i++) {
		string s;
		cin >> s;
		for(int j = 0; j < 15; j++) {
			if(s[j] == 'O') sx = j, sy = i;
			if(s[j] == 'X') {
				b[i][j] = B++;
			}
		}
	}

	S is = { sx, sy, 0 };
	dp[is.hash()] = 0;

	queue<S> q;
	q.push(is);
	while(q.size()) {
		int x = q.front().x, y = q.front().y, mask = q.front().mask;
		int t = dp[q.front().hash()];
		q.pop();
		for(int k = 0; k < 8; k++) {
			int nx = x + dx[k], ny = y + dy[k];
			if(!in(nx, ny)) continue;
			int id = b[ny][nx];
			if(id == -1) continue;
			if(mask >> id & 1) continue;
			int nmask = mask;
			while(1) {
				nmask |= 1 << id;
				nx += dx[k], ny += dy[k];
				if(!in(nx, ny)) break;
				id = b[ny][nx];
				if(id == -1 || (mask >> id & 1)) break;
			}
			if(in(nx, ny) && ny == 18 || ny == 19) {
				printf("%d\n", t + 1);
				return 0;
			}
			if(in(nx, ny)) {
				S ns = { nx, ny, nmask };
				if(dp.count(ns.hash()) == 0) {
					dp[ns.hash()] = t + 1;
					q.push(ns);
				}
			}
		}
	}
	printf("-1\n");
}

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


int main(){
	string S;
  	cin>>S;
  	int act=0,bct=0,cct=0;
  	for(int k=0;k<S.size();k++){
      if(S.at(k)=='a') act++;
      else if(S.at(k)=='b') bct++;
      else cct++;
    }
  
  	if(act==0){if((cct==0&&bct==1)||(bct==1&&cct==1))cout<<"YES"<<endl;else cout<<"NO"<<endl; return 0;}
	if(bct==0){if((act==0&&cct==1)||(act==1&&cct==1))cout<<"YES"<<endl;else cout<<"NO"<<endl; return 0;}
	if(cct==0){if((bct==0&&act==1)||(bct==1&&act==1))cout<<"YES"<<endl;else cout<<"NO"<<endl; return 0;}
               
               
	 if(act<=bct&&act<=cct){
      	if(bct-act<=1&&cct-act<=1) cout<<"YES"<<endl;
      	else cout<<"NO"<<endl;
       return 0;
     }else if(bct<=act&&bct<=cct){
      	if(act-bct<=1&&cct-bct<=1) cout<<"YES"<<endl;
      	else cout<<"NO"<<endl;
       return 0;
     }else if(cct<=bct&&cct<=act){
      if(bct-cct<=1&&act-cct<=1) cout<<"YES"<<endl;
      else cout<<"NO"<<endl;
       return 0;
	}
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include "./libb/lib.hpp"

using namespace std;
const uint64_t MOD = 1000000007;
const double PI = acos(-1);

int main()
{
    string aa = "ABC";
    string bb = "ARC";
    string temp;
    cin >> temp;

    if(temp == aa){
      cout << bb << endl;
    }else{
      cout << aa << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func main() {
	arr := make([]int, 3)
	var k uint

	fmt.Scanf("%d %d %d", &arr[0], &arr[1], &arr[2])
	fmt.Scanf("%d", &k)

	maxIndex := 0

	for i := 1; i < 3; i++ {
		if arr[i] > arr[maxIndex] {
			maxIndex = i
		}
	}

	arr[maxIndex] <<= k

	fmt.Printf("%d", arr[0]+arr[1]+arr[2])

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n)     for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n)    for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n)   for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v)  for (auto &&V : v)
#define all(x)        (x).begin(), (x).end()
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = 1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int a, b;
  cin >> a >> b;
  int sum = 1, cnt = 0;
  while (sum < b) {
    sum += a - 1;
    ++cnt;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int h, w;
	cin >> h >> w;

	char c;
	int count = 0;
	REP(i, h){
		REP(j, w){
			cin >> c;
			if (c == '#') count++;
		}
	}

	if (count == h + w - 1) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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; }
const ll MOD = 1e9+7;

int main(){
    ll Q, H, S, D;
    cin >> Q >> H >> S >> D;
    ll N; 
    cin >> N;

    ll A = 4*Q;
    chmin(A, 2*H);
    chmin(A, S);

    ll ans = 0;
    if(2*A > D){
        ans += D * (N/2);
        ans += A * (N % 2);
    }
    else{
        ans += A*N;
    }

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


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define en '\n'
#define rep(i,n)    for(ll i=0; i<n; i++)
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(1);
#define yes cout<<"YES"<<'\n'
#define no cout<<"NO"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll i,a,b,k;
    string s;
    cin>>a>>b>>k;
    for(i=1; i<=k; i++)
    {
        if(i%2)
        {
            if(a%2)
                a--;
                b+=a/2;
                a/=2;

    // cout<<1<<" "<<a<<" "<<b<<endl;
        }
        else
        {
            if(b%2)
                b--;

                a+=b/2;
                b/=2;
     //cout<<2<<" "<<a<<" "<<b<<endl;
        }

    }
     cout<<a<<" "<<b<<endl;

    return 0;
}





Measured memory_bytes: 3644
# include <cstdio>
# include <map>
# include <cmath>

using namespace std;

const int mod = 1e9+7;

int main()
{
	int n;
	int  a[100005];
	map<int,int> m;
	scanf("%d",&n);
	
	for(int i = 0;i < n;i++)
	{
		scanf("%d",&a[i]);
		m[a[i]]++;
	}

	int flag = 0; 
	if(n%2) //奇数 
	{
		if(m[0] != 1)
		{
			flag = 1;
		}
		for(int i = 2;i < n;i+=2)
		{
			if(m[i] != 2)
			{
				flag = 1;
			}
		}
	}else{
		for(int i = 1;i < n;i+=2)
		{
			if(m[i] != 2)
			{
				flag = 1;
			}
		}
	}
	long long sum = 1;
	
	for(int i =0;i < floor(n/2);i++)
	{
		sum = ((sum % mod) * 2)% mod;
	}
	
	if(n%2)
	{
		if(flag)
		printf("0\n");
		else
		printf("%lld\n",sum);
	}	
	else
	{
		if(flag)
		printf("0\n");
		else
		printf("%lld\n",sum);
	}

	return 0;
 } 

Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin >> n >> k;
  ll ans= 0;
  rep(i,n){
      ll tmp ;cin >> tmp;
      if(tmp>=k)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
#define ll long long
 
ll MOD=1e9+7;
ll a[100005];
using namespace std;
 
int main(){
	ll n;
	cin>>n;
	
	ll flag=1;//flag 
	ll ans=1;
	
	if(n%2==0){ // even number 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;//a[7]++
			
			// give data x error 
			if(x>=n || x%2==0 || a[x]>2){ 
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//The correct situation 
			if(a[x]==1)
				ans=ans*2%MOD; // a * b %c == a%c * b%c 
		}
	} 
	
	else{ //odd 
	
		for(ll i=0;i<n;i++){
			ll x;
			cin>>x;
			a[x]++;
			
			// give data x error 
			if(x>=n || x%2==1 || a[0]>1 ||a[x]>2){
				flag=0;
				cout<<"0"<<endl;
				break;
			}
			
			//The correct situation
			if(x!=0 && a[x]==1)
				ans=ans*2%MOD;
		}
	}
	
	if(flag)
		cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4332
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


int num[100010];
bool red[100010];

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

    rep(i, 100010) num[i] = 1;
    red[0] = 1;

    rep(i, m){
        int x, y;
        cin >> x >> y;
        x--, y--;
        if (red[x] && num[x] > 1) red[y] = 1;
        else if (red[x] && num[x] == 1) red[x] = 0, red[y] = 1;
        num[x]--, num[y]++;
    }

    int ans = 0;
    rep(i, n) if (red[i]) ans++;
    cout << ans << endl;
    
    return 0;
}


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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

struct segtree {
    int n;
    vector<long long> T, U;

    segtree() = default;

    segtree(int n) : n(n) {
        T.assign(4 * n, 1ll * MOD * MOD);
        U.assign(4 * n, 0);
    }

    void push(int v) {
        T[2 * v] += U[v];
        U[2 * v] += U[v];
        T[2 * v + 1] += U[v];
        U[2 * v + 1] += U[v];
        U[v] = 0;
    }

    void upd(int lq, int rq, long long x, int v, int l, int r) {
        if (r < lq || l > rq)
            return ;

        if (lq <= l && r <= rq) {
            T[v] += x, U[v] += x;
            return ;
        }

        push(v);
        auto m = (l + r) / 2;
        upd(lq, rq, x, 2 * v, l, m);
        upd(lq, rq, x, 2 * v + 1, m + 1, r);
        T[v] = min(T[2 * v], T[2 * v + 1]);
    }

    long long get(int lq, int rq, int v, int l, int r) {
        if (r < lq || l > rq) return 5ll * MOD * MOD;
        if (lq <= l && r <= rq) return T[v];
        auto m = (l + r) / 2;
        push(v);
        return min(get(lq, rq, 2 * v, l, m), get(lq, rq, 2 * v + 1, m + 1, r));
    }

    void upd(int lq, int rq, long long x) { upd(lq, rq, x, 1, 0, n - 1); }
    long long get(int lq, int rq) { return get(lq, rq, 1, 0, n - 1); }
};

int n, m;
long long A, B;
long long x[N];
segtree T[2][2];

bool read() {
    if (!(cin >> n >> m >> A >> B))
        return false;

    for (int i = 0; i < m; ++i)
        cin >> x[i + 2];

    return true;
}

int solve() {
    m += 2;
    x[0] = A;
    x[1] = B;

    for (int k = 0; k < 4; ++k)
        T[k / 2][k % 2] = segtree(n + 1);

    T[1][0].upd(A, A, -1ll * MOD * MOD - A);
    T[1][1].upd(A, A, -1ll * MOD * MOD + A);

    for (int i = 1; i < m - 1; ++i) {
        vector<long long> mm = {
            min(x[i + 1] + T[1][0].get(0, x[i + 1]), T[1][1].get(x[i + 1], n) - x[i + 1]),
            min(x[i + 1] + T[0][0].get(0, x[i + 1]), T[0][1].get(x[i + 1], n) - x[i + 1])
        };

        for (int k = 0; k < 4; ++k)
            T[k / 2][k % 2].upd(0, n, abs(x[i + 1] - x[i]));

        for (int k = 0; k < 4; ++k) {
            auto cur = T[k / 2][k % 2].get(x[i], x[i]);

            if (cur > mm[k / 2] + x[i] * (k % 2 ? 1 : -1))
                T[k / 2][k % 2].upd(x[i], x[i], mm[k / 2] + x[i] * (k % 2 ? 1 : -1) - cur);
        }
    }

    auto ans = 5ll * MOD * MOD;

    for (int i = 0; i < m; ++i)
        for (int k = 0; k < 4; ++k)
            ans = min(ans, T[k / 2][k % 2].get(x[i], x[i]) + x[i] * (k % 2 ? -1 : 1));

    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 51840
def gcd(a, b)
  return gcd(b, a) if b > a
  return a if b == 0
  gcd(b, a % b)
end

def lcm(a, b)
  g = gcd(a, b)
  a * b / g
end

a, b, c, d = gets.split.map(&:to_i)

l = lcm(c, d)

puts (b-a+1) - (b/c + b/d - b/l - ((a-1)/c + (a-1)/d - (a-1)/l))

Measured memory_bytes: 1788
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
  
  for(let i=0;i<lines.length;i++){
    if(lines[i] == 0){
      continue;
    }
    console.log('Case ' + (i + 1) + ': ' + lines[i]);
  }
});


Measured memory_bytes: 23316
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin>>K;
  K--;
  cout<<a[K]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
using namespace std;
int x[100],y[100],dp[100][100010];
signed main(){
	int a,b;
	cin>>a>>b;
	f(i,100){
		f(j,100010){
			if(j)dp[i][j]=LLONG_MAX/2;
		}
	}
	f(i,a){
		cin>>y[i]>>x[i];
		f(j,x[i]){
			if(i) dp[i][j]=dp[i-1][j];
		}
		for(int j=x[i];j<=100000;j++){
			if(i) dp[i][j]=min({dp[i][j],dp[i-1][j-x[i]]+y[i],dp[i-1][j]});
		}
		if(i==0) dp[i][x[i]]=y[i];
	}
	int ans=0;
	f(i,100010){
		if(dp[a-1][i]<=b) ans=max(ans,i);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 78336
#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import functools
import heapq
import logging
import math
import random
import string
import sys
from argparse import ArgumentParser
from collections import defaultdict
from copy import deepcopy


def solve(values, nb):
    cost_to = [0] * nb
    cost_to[1] = abs(values[1] - values[0])
    for i in range(2, nb):
        cost_to[i] = min(
            cost_to[i - 2] + abs(values[i] - values[i - 2]),
            cost_to[i - 1] + abs(values[i] - values[i - 1]),
        )
    return cost_to[nb - 1]


def do_job():
    "Do the work"
    LOG.debug("Start working")
    # first line is number of test cases
    N = int(input())
    values = list(map(int, input().split()))
    result = solve(values, N)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def configure_log(log_file=None) -> None:
    "Configure the log output"
    log_formatter = logging.Formatter(
        "%(asctime)s - %(filename)s:%(lineno)d - " "%(levelname)s - %(message)s"
    )
    if log_file:
        handler = logging.FileHandler(filename=log_file)
    else:
        handler = logging.StreamHandler(sys.stdout)
    handler.setFormatter(log_formatter)
    LOG.addHandler(handler)


LOG = None
# for interactive call: do not add multiple times the handler
if not LOG:
    LOG = logging.getLogger("template")
    configure_log()


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    parser = ArgumentParser()
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbose",
        action="store_true",
        default=False,
        help="run as verbose mode",
    )
    args = parser.parse_args(argv)
    if args.verbose:
        LOG.setLevel(logging.DEBUG)
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


Measured memory_bytes: 18500
#include<stdio.h>

int main(void)
{
  int a,b;
  int i;
  

  for(i = 0; ;i++)
    {
      scanf("%d %d",&a,&b);
      if( a == 0 && b == 0)
	break;

      if( a < b )
	{
	  printf("%d %d\n",a,b);
	}
      else
	{
	  printf("%d %d\n",b,a);
	}
    }
  return 0;

}



Measured memory_bytes: 2056
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,k,x;
ll ans,dp[10][10];
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=0;i<=9;i++)for(j=0;j<=9;j++)cin>>dp[i][j];
	for(k=0;k<=9;k++)for(i=0;i<=9;i++)for(j=0;j<=9;j++)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++)
	 {
		cin>>x;
		if(x!=-1)ans+=dp[x][1];
	 }
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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 modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int R, G, B, N;
  cin >> R >> G >> B >> N;

  ll ans = 0;
  for(int r = 0; r * R <= N; r++){
    for(int g = 0; r * R + g * G <= N; g++){
      
      if((N-r*R-g*G) % B == 0){
        ans++;
      }

    }
  }

  cout << ans << endl;


  return 0;
}


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

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

int main(){
   int a,b,c;
   cin>>a>>b>>c;
   if(a==b){
       cout<<c<<endl;
   }
   else if(b==c){
       cout<<a<<endl;
   }
   else{
       cout<<b<<endl;
   }
    return 0;
}

Measured memory_bytes: 256
// Pratiyush Mishra(pratiush7)
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repab(i,a,b) for(ll i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define pr1(x) cout<<fixed<<setprecision(15)<<x<<'\n'
#define mod 1000000007
#define mod1 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getvec(v,n) vector<ll> v(n);for(ll i=0;i<n;i++) cin>>v[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);get(x);
  if(n*(ll)500>=x)
    p1("Yes");
  else
    p1("No");
  return 0;
}


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

using namespace std;

int main(){
    int n, x;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    double ans = (double)v[0];
    for(int i = 0; i < n; i++){
        ans=(ans+(double)v[i])/2;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector <string> v;
vector<int> num;
string s ;
int main(){
  int N;
  cin >> N;
  for(int i = 0;i < N;i++){
    int x;
    cin >> x;
    num.push_back(x);
  }

  sort(num.begin(),num.end());
  num.erase((unique(num.begin(),num.end())),num.end());

  cout << (int)num.size()<<endl;

  return 0;
}


Measured memory_bytes: 256