akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main() {
	int N,M;
	cin >> N >> M;
	vector<int> v(M);
	for (int i = 0; i < M; i++) {
		cin >> v[i];
	}
	if (N >= M) {
		cout << 0 << endl;
		return 0;
	}
	sort(v.begin(), v.end());
	vector< pair<int, int> > diff(M-1);
	for (int i = 0; i < M-1; i++) {
		diff[i].first = v[i+1] - v[i];
		diff[i].second = i;
	}
	sort(diff.begin(), diff.end());
	vector< int > pos(N);
	vector<int> pdiff(N);
	pos[0] = 0;
	for (int i = 1; i < N; i++) {
		pos[i] = diff[M-1-i].second+1;
	}
	sort(pos.begin(), pos.end());
	for (int i = 0; i < N-1; i++) {
		pdiff[i] = pos[i+1]-1 - pos[i];
	}
	pdiff[N-1] = M-1 - pos[N-1];
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += v[pdiff[i]+pos[i]] - v[pos[i]];
	}
	cout << ans << endl;
	return 0;
}



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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int c=sc.nextInt();
		int d=sc.nextInt();
		if(a*b>c*d)System.out.println(a*b);
		else System.out.println(c*d);
	}

}


Measured memory_bytes: 10192
fn main() {
    let mut sc = Scanner::new();
    let s: Vec<char> = sc.read::<String>().chars().collect();
    let mut count = vec![0; 26];
    for &c in &s {
        count[(c as u8 - 'a' as u8) as usize] += 1;
    }

    let n = s.len();
    let mut ans = n * (n - 1) / 2;
    for &c in &count {
        if c == 0 { continue; }
        ans -= c * (c - 1) / 2;
    }

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

struct Scanner {
    ptr: usize,
    length: usize,
    buf: Vec<u8>,
    small_cache: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner { ptr: 0, length: 0, buf: vec![0; 1024], small_cache: vec![0; 1024] }
    }

    fn load(&mut self) {
        use std::io::Read;
        let mut s = std::io::stdin();
        self.length = s.read(&mut self.buf).unwrap();
    }

    fn byte(&mut self) -> u8 {
        if self.ptr >= self.length {
            self.ptr = 0;
            self.load();
            if self.length == 0 {
                self.buf[0] = b'\n';
                self.length = 1;
            }
        }

        self.ptr += 1;
        return self.buf[self.ptr - 1];
    }

    fn is_space(b: u8) -> bool { b == b'\n' || b == b'\r' || b == b'\t' || b == b' ' }

    fn read<T>(&mut self) -> T where T: std::str::FromStr, T::Err: std::fmt::Debug, {
        let mut b = self.byte();
        while Scanner::is_space(b) {
            b = self.byte();
        }

        for pos in 0..self.small_cache.len() {
            self.small_cache[pos] = b;
            b = self.byte();
            if Scanner::is_space(b) {
                return String::from_utf8_lossy(&self.small_cache[0..(pos + 1)]).parse().unwrap();
            }
        }

        let mut v = self.small_cache.clone();
        while !Scanner::is_space(b) {
            v.push(b);
            b = self.byte();
        }
        return String::from_utf8_lossy(&v).parse().unwrap();
    }
}



Measured memory_bytes: 4352
#include<stdio.h>

int main(){
  int x,n,i,s=0;
  int a[101]={0};
  scanf("%d %d",&n,&x);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    s=a[i]+s;
    if(x<s)
      break;
  }
   printf("%d",i+1);
}

Measured memory_bytes: 128
S = input()

w = 'keyence'
l = len(w)
flag = False
for i in range(l):
	f = w[:i]
	b = w[-(l-i):]
	sf = S[:i]
	sb = S[-(l-i):]
	if f == sf and b == sb:
		print('YES')
		flag = True
		break

if not flag:
	print('NO')


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,n,a[200005],ans=10000000;
    cin>>k>>n;
    for(int i=0;i<n;i++){
      cin>>a[i];
    }      
    for(int i=1;i<n;i++){
      if(ans>k-(a[i]-a[i-1])){
      ans=k-(a[i]-a[i-1]);
      }
    }
    if(ans>(a[n-1]-a[0])){
      ans=(a[n-1]-a[0]);
    }
    cout<<ans<<endl;
    return(0);
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  int a, b, c;
  LL k;
  Read(a), Read(b), Read(c), Read(k);
  if (k & 1) {
    printf("%d\n", b - a);
  } else {
    printf("%d\n", a - b);
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
/* #define int long long */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;

    for(ll i = 1; i < n; i++){
        if(a[i] < a[i-1]){
            ll tmp = a[i-1] - a[i];
            ans += tmp;
            a[i] += tmp;
        }
    }

    cout << ans << endl;
}

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

class UnionFind_t {
private:
  vector<int> par;
public:
  void init(int size){
    par.resize(size);
    for (int n = 0; n < size; n++){
      par[n] = n;
    }
  }

  UnionFind_t(int size){
    init(size);
  }

  int Root(int x){
    if (par[x] == x){
      return x;
    }else{
      int r = Root(par[x]);
      par[x] = r;
      return r;
    }
  }

  void Union(int x, int y){
    x = Root(x);
    y = Root(y);
    if (x == y){
      return;
    }
    par[x] = y;
  }

  int FindMax(){
    vector<int> mc(par.size(), 0);
    int r = 0;

    for (int n = 0; n < par.size(); n++){
      int rt = Root(n);
      mc.at(rt)++;
      if (mc.at(rt) > r){
	r = mc.at(rt);
      }
    }
    return r;
  }
    
  void Print(){
    int n;
    cout << "idx: ";
    for (n = 0; n < par.size(); n++){
      cout << n << " ";
    }
    cout << endl;

    cout << "par: ";
    for (n = 0; n < par.size(); n++){
      cout << par[n] << " ";
    }
    cout << endl;

    cout << "rot: ";
    for (n = 0; n < par.size(); n++){
      cout << Root(n) << " ";
    }
    cout << endl;
  }
  
};

int main(){
  int N, M;
  cin >> N >> M;
  
  UnionFind_t uf(N+1);

  for (int m = 0; m < M; m++){
    int a, b;
    cin >> a >> b;
    uf.Union(a,b);
  }

  //uf.Print();
  cout << uf.FindMax() << endl;

  return 0;
}


Measured memory_bytes: 10960
from collections import defaultdict as dd
import sys
N = int(input())
D = dd(int)
D["M"] = 0
D["A"] = 0
D["R"] = 0
D["C"] = 0
D["H"] = 0

for i in range(N):
  s = input()[0]
  if any((s == "M", s == "A", s == "R", s == "C", s == "H")):
    D[s] += 1
ans = 0
tpls = (("M","A","R"),("M","A","C"),
        ("M","A","H"),("M","R","C"),
        ("M","R","H"),("M","C","H"),
        ("A","R","C"),("A","R","H"),
        ("A","C","H"),("R","C","H"))

for t in tpls:
    ans += D[t[0]] * D[t[1]] * D[t[2]]
print (ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

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

    int n; cin >> n;
    using Elem = tuple<int, int>;
    vector<Elem> xs(n), ys(n);
    rep(i, n){
        int x, y; cin >> x >> y;
        xs[i] = Elem(x, i);
        ys[i] = Elem(y, i);
    }
    sort(_all(xs));
    sort(_all(ys));

    using Edge = tuple<int, int, int>;
    vector<Edge> edges;
    auto f = [&](vector<Elem>& p){
        rep(i, n - 1){
            int v, x; tie(x, v) = p[i];
            int nv, nx; tie(nx, nv) = p[i + 1];
            edges.emplace_back(Edge(nx - x, v, nv));
        }
    };
    f(xs); f(ys);
    sort(_all(edges));

    UnionFind uf(n);
    ll res = 0LL;
    for(auto& e : edges){
        int a, b, cost; tie(cost, a, b) = e;
        if(uf.findSet(a, b)) continue;
        uf.unionSet(a, b);
        res += cost;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 7540
/*
 * ----------------------------------------------------------------------------
 (: Bismillahir Rahmanir Rahim :) 
 * File: /root/Programming/Atcoder/A_Circle_Pond.cpp
 * Project: /root/Programming/Atcoder
 * Created Date: Sunday, April 19th 2020, 6:04:13 pm
 * Author: Grim Firefly :)
 * Author Mail : GrimFirefly1@gmail.com
 * -----
 * Last Modified: Sun Apr 19 2020
 * Modified By: Grim Firefly :)
 * -----
 * ----------------------------------------------------------------------------
 */

//Code Start
#include <bits/stdc++.h>
using namespace std;

//constant
#define PI acos(-1.0)

//typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned un;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef map<int, int> mii;
typedef map<char, char> mcc;
typedef map<char, int> mci;
typedef map<string, int> msi;
typedef map<ll, ll> mll;
typedef set<int> seti;
typedef set<ll> setl;
typedef queue<int> qui;
typedef deque<int> dqui;

//Debug Setting up
#define watch(x) cout << (#x) << " is " << x << endl
#define watchara(wow)  \
    for (auto x : wow) \
    cout << x << " "

//defining something
#define SZ 10000

//main function start

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

    int x;
    scanf("%d",&x);
    printf("%.03lf\n", 2.0 * x * PI);

    return 0;
}

Measured memory_bytes: 3852
#include <stdio.h>

int main(void)
{
    int n, y;
    int a, b, c;
    int flg = 0;

    scanf("%d %d", &n, &y);

    for (a = 0;a <= n && flg != 1;a++) {
        for (b = 0;b <= n && flg != 1;b++) {
            c = n - a - b;
            if (-1 < c) {
                if ((y == (10000 * a + 5000 * b + 1000 * c)) && n == (a + b + c)) {
                    printf("%d %d %d\n", a, b, c);
                    flg = 1;
                    break;
                }
            }
        }
    }
    if (flg != 1) {
        printf("-1 -1 -1\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<long long> s;
  long long t = 0;
  for(int i = 0; i < n; i++){
    int a; cin >> a;
    t+= a;
    s.push_back(t);
  }
  long long a = abs((s[n-1] - s[0]) - s[0]);
  for(int i = 0; i < n-1; i++){
    if(a > abs((s[n-1] - s[i]) - s[i])) a = abs((s[n-1] - s[i]) - s[i]);
  }
  cout << a << endl;
}


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

int main(void){
	int n, b, f, r, v, ko[4][3][10];
	
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 3; ++j){
			for(int k = 0; k < 10; ++k){
				ko[i][j][k] = 0;
			}
		}
	}
	
	cin >> n;
	for(int i = 0; i < n; ++i){
		cin >> b >> f >> r >> v;
		ko[b-1][f-1][r-1] += v;
	}
	
	for(int i = 0; i < 4; ++i){
		for(int j = 0; j < 3; ++j){
			for(int k = 0; k < 10; ++k){
				printf(" %d", ko[i][j][k]);
			}
			printf("\n");
		}
		if(i != 3){
			printf("####################\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b)
{
    return b ? gcd(b, a % b) : a;
}

int main(){
    int n;
    cin >> n;
    ll maxv = 0;
    vector<ll> v(n+1);
    for (int i = 1; i < n+1; i++)
    {
        cin >> v[i];
    }
    vector<ll> l(n+2);
    vector<ll> r(n+2);
    l[1] = 0;
    for (int i = 2; i < n+1; i++)
    {
        l[i] = gcd(l[i - 1], v[i - 1]);

    }
    r[n] = v[n];
    for (int j = n - 1; j > 0; j--)
    {
        r[j] = gcd(r[j + 1], v[j]);
    }

    for (int i = 1; i < n+1; i++)
    {
        maxv = max(maxv, gcd(l[i], r[i + 1]));
    }
    cout << maxv << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", &a[i]);
    int x = accumulate(a, a+n, 0, [](int s, int t){return s ^ t;});
    rep(i, n) printf("%d ", a[i] ^ x);
    printf("\n");
}

Measured memory_bytes: 4480
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <iomanip>
#include <map>
#include <queue>
#include <list>

#define REP(i, n ,N) for(ll i = (n); i < (N); i++)
//#define RREP(i, n ,N) for(ll i = (N-1); i >= (n); i--)
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define vint vector<int>
#define INF 1e9
#define PI 3.14159265359

using namespace std;
typedef long long  ll;

const long long MOD = 1e9+7;


int main(){

    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;
    if(w - v >= 0){
        p("NO");
        return 0;
    }
//    p(double (abs(a - b)) / double (v - w));
    if(double (abs(a - b)) / double (v - w) <= double (t)){
        p("YES");
    } else {
        p("NO");
    }

    return 0;
}


Measured memory_bytes: 3100
/*author:anshumanc007
   created on:08/01/2019
            */
//EMBRACE THE STRUGGLE!!!
#include <bits/stdc++.h>
#include <queue>
#include <stack>
using namespace std;
//typedef pair<long long int,long long int> pa;
#define MAX 100005
long long int MOD=1e9+7;
long long int INF=1e18;
long long int dp[1005][1005];


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int i,j,k,l,m,n,o,p,q,r,x,y,a,b,mini=INF,maxi=0,cnt=0,W,ans;
    cin>>n>>m;
    string s[n+1];
    for(i=1;i<=n;i++)
    {
        cin>>s[i];
        s[i]='#'+s[i];
      // cout<<s[i]<<endl;
    }
    s[0]="";
    for(i=0;i<=m;i++)
    { 
        s[0]=s[0]+'#';
    }
//cout<<s[0]<<endl;
    
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            dp[i][j]=0;
        }
    }
    dp[1][1]=1;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
           
            if(s[i-1][j]!='#')
             dp[i][j]=(dp[i][j]+dp[i-1][j])%MOD;
            if(s[i][j-1]!='#')
              dp[i][j]=(dp[i][j]+dp[i][j-1])%MOD; 
            
        }
    }
    cout<<dp[n][m]<<endl;
    

    
}

Measured memory_bytes: 9088
#include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  int xmin = max(0, s - 2 * k);
  int xmax = min(k, s);
  for (int i = xmin; i <= xmax; i++) {
    int ymin = max(0, s - i - k);
    int ymax = min(k, s - i);
    for (int j = ymin; j <= ymax; j++) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <tuple>
#include <string>
#include <iterator>
#include <regex>
using namespace std;

int main()
{
    int N, rt = 0;
    cin >> N;
    char c;
    map<char, vector<int> > mp;
    map<int, bool> line;
    for (int i = 0; i < N; i++) {
        cin >> c;
        mp[c].push_back(i);
    }
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second.size() > 1) {
            line[itr->second.front()] = true;
            line[itr->second.back()] = false;
        }
    }
    int count = 0;
    for (auto itr = line.begin(); itr != line.end(); ++itr) {
        if (itr->second) count++;
        else count--;
        rt = max(rt, count);
    }
    cout << rt << endl;
    return 0;
}

Measured memory_bytes: 384
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
long bignum = 1_000_000_007;

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, t;
    scan(n, t);
    auto l = aryread();
    long shower;
    foreach (i; 0 .. n)
    {
        if (i == 0)
            continue;

        if (l[i - 1] + t > l[i])
        {
            shower += l[i] - l[i - 1];
        }
        else
        {
            shower += t;
        }
    }
    shower += t;
    shower.writeln();
}


Measured memory_bytes: 10584
# diverta 2019 Programming Contest: B – RGB Boxes
R, G, B, N = [int(i) for i in input().split()]

bingo = 0

for r in range(0, 3001):
    if R * r > N:
        break
    else:
        for g in range(0, 3001):
            b = (N -(R * r + G * g)) // B
            if b < 0:
                break
            elif R * r + G * g + B * b == N:
                bingo += 1

print(bingo)

Measured memory_bytes: 9096
N = int(input())
A = list(map(int, input().split()))
m = sum(A) // 2
n = 0
if N > 2:
  for i in range(N):
    if n < m:
      n += A[i]
    elif n >= m and i == N - 1:
      a = i
    elif n >= m and i != N - 1:
      a = i
      break
  if a == 0:
    print(abs(A[a]-sum(A[a:])))
  elif abs(sum(A[:a-1]) - sum(A[a-1:])) > abs(sum(A[:a]) - sum(A[a:])):
    print(abs(sum(A[:a]) - sum(A[a:])))
  else:
    print(abs(sum(A[: a - 1]) - sum(A[a - 1 :])))
else:
  print(abs(A[0]-A[1]))

Measured memory_bytes: 26024
#include <stdio.h>

int main(void){
  int s;
  scanf("%d", &s);
  if(s%9==0){
    printf("0\n");
  }else if(s%9==1){
    printf("1\n");
  }else if(s%9==2){
    printf("2\n");
  }else{
    printf("3\n");
  }
  
  return 0;
}

Measured memory_bytes: 1612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <climits>
#include <utility>
#include <numeric>
typedef long long ll;
using namespace std;

const ll MID = 1e9 / 2;

struct P{
  ll x, y, dist;
  ll x2, y2;

  P(ll x_, ll y_)
    :x(x_), y(y_)
  {
    dist = (x - MID) + (y - MID);
  }

  bool operator <(const P &x) const{
    return dist < x.dist;
  }
};

int main(int argc, char *argv[]) {
  int n, i;
  cin >> n;

  ll x, y;
  ll min[2], max[2];

  cin >> x >> y;
  min[0] = x - y;
  max[0] = x - y;
  min[1] = x + y;
  max[1] = x + y;
  
  for(i=1;i<n;i++){
    cin >> x >> y;

    if(min[0]>x-y) min[0] = x - y;
    if(max[0]<x-y) max[0] = x - y;
    if(min[1]>x+y) min[1] = x + y;
    if(max[1]<x+y) max[1] = x + y;
  }

  ll ans = max[0]-min[0];
  if(ans<max[1]-min[1]) ans = max[1]-min[1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3664
while 1:
    n = int(input())
    if n == 0:
        break
    point = [int(input()) for i in range(n)]
    point.sort()
    Sum = 0
    hito = 0
    for i in range(1,n-1):
        Sum += point[i]
        hito += 1
    ans = Sum // hito
    print(ans)




Measured memory_bytes: 5604
import sys
sys.setrecursionlimit(100000000)

lst = []
def dfs(N, n, s):
    if n == N:
        lst.append(s)
        return
    s_ = s*10
    s0 = s%10
    if s0 == 0:
        for i in range(0, 2):
            dfs(N, n+1, s_+i)
    elif s0 == 9:
        for i in range(8, 10):
            dfs(N, n+1, s_+i)
    else:
        for i in range(s0-1, s0+2):
            dfs(N, n+1, s*10+i)

K = int(input())
for i in range(1, 11):
    for j in range(1, 10):
        dfs(i, 1, j)
print(lst[K-1])

Measured memory_bytes: 73308
A,B,M = map(int,input().split())
AA = map(int,input().split())
AAA = list(AA)
BB = map(int,input().split())
BBB = list(BB)
mini = min(AAA) + min(BBB)
for i in range(M):
  x,y,c = map(int,input().split())
  xxx = AAA[x-1] + BBB[y-1] - c
  if mini >xxx:
    mini = xxx
print(mini)

Measured memory_bytes: 24852
object Main {
  // NOTE: Destructive: arr
  def printInsertSort(arr: Array[Int]): Unit= {
    for (i <- (1 until arr.length)) {
      // Print arr
      println(arr.mkString(" "))
      val v = arr(i)
      var j = i - 1
      while(j >= 0 && arr(j) > v) {
        arr(j+1) = arr(j)
        j -= 1
      }
      arr(j+1) = v
    }
    // Print arr
    println(arr.mkString(" "))
  }

  def main(args: Array[String]): Unit = {
    // Skip n
    io.StdIn.readLine()

    // Read arry string
    var arrString: String = io.StdIn.readLine()
    // Convert it to real int array
    val arr: Array[Int] = arrString.split(" ").map(_.toInt)

    // Print insert sort step
    printInsertSort(arr)
  }
}


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

void setCnt(int n);
void clearCnt();
void loop(int x, int y);

const int MAX = 16;
int a, b, cnt[MAX][MAX][1];

int main(){
    while(cin >>a >>b){
        if(a == 0 && b == 0) break;
        int n;
        cin >>n;
        clearCnt();
        setCnt(n);
        loop(1, 1);
        cout <<cnt[a][b][0] <<endl;
    }
    return 0;
}
void clearCnt(){
    for(int i = 0; i < MAX; i++){
        for(int j = 0; j < MAX; j++){
            cnt[i][j][0] = 0;
        }
    }
}
void setCnt(int n){
    for(int i = 0; i < n; i++){
        int x, y;
        cin >>x >>y;
        cnt[x][y][0] = -1;
    }
}
void loop(int x, int y){
    int goX[2] = {0, 1}, goY[2] = {1, 0};
    for(int i = 0; i < 2; i++){
        int nextX = x + goX[i], nextY = y + goY[i];
        if(nextX <= a && nextY <= b && cnt[nextX][nextY][0] >= 0){
            cnt[nextX][nextY][0]++;
            loop(nextX, nextY);
        }
    }
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int i; cin >> i;
	ll sum = 0;
	for(int n = 1 ; n <= i ; n++){
		if(n%3==0 && n%5==0)
			continue;
		else if(n%3==0)
			continue;
		else if(n%5==0)
			continue;
		else
			sum+=n;
	}
	cout<<sum<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3640
import java.util.List;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Set;
import java.util.Map;
import java.util.HashMap;
import javax.swing.text.DefaultStyledDocument.ElementSpec;

import java.util.HashSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] a = new int[3];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        a[2] = sc.nextInt();
        Arrays.sort(a);
        int x = Integer.parseInt(Integer.toString(a[2]) + Integer.toString(a[1]));
        System.out.println(x + a[0]);
    }
}

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

int main(){
    string p,s;
    cin>>p>>s;
    p=p+p;
    bool flag=false;
    for(int i=0;i<(int)p.size()-(int)s.size()+1;i++){
        string t=p.substr(i, s.size() );
        
        if(t==s){
            flag=true;
            break;
        }
    }
    if(flag){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3180
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

int X;
signed main(){
    scanf("%lld",&X);
    int ans=0;int money=100;
    while(true){
        ans++;
        money=money*1.01;
        if(money>=X)break;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for (int i = k; i < (int)(n); i++)
#define repd(i, n) for (int i = n-1; i >= 0; i--)
#define rrepd(i, k, n) for (int i = n-1; i >= (int)(k); i--)
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
//V,Pは大文字i,l,bは小文字
using ll = long long;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
using P = pair<int,int>;
using Pll = pair<ll, ll>;
const ll mod = 1000000007;
const ll inf = 1000000000000;//10の12乗
long long keta(long long x){
  int y=0;
  while(x!=0){
    y++;
    x/=10;
  }
  return y;
}

int main() {
  int a,b;
  cin >> a >> b;
  int k=keta(b);
  a=a*pow(10,k);
  int ab=a+b;
  rep(i,1000){
    int now=i*i;
    if(ab==now){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    int n;
    cin>>n;
    vdo x(n);
    vstr u(n);
    rep(i,n)cin>>x[i]>>u[i];
    double sum=0;
    rep(i,n){
        if(u[i]=="JPY")sum+=x[i];
        else sum+=(double)380000*x[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc138/tasks/abc138_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String s = sc.next();
		sc.close();

		if(a>=3200) {
			System.out.println(s);

		}else {
			System.out.println("red");
		}
	}

}


Measured memory_bytes: 23252
import java.util.*;

public class Main{
	public static void main(String[] args){
		//new Main().printHelloWorld();
		//System.out.println(new Main().ITP1_1_B(Integer.parseInt(new Scanner(System.in).next())));
		//new Main().ITP1_1_C();
		//new Main().ITP1_1_D();
		//new Main().ITP1_2_A();
		//new Main().ITP1_2_B();
		//new Main().ITP1_2_C();
		new Main().ITP1_2_D();
	}

	public void printHelloWorld(){
		System.out.println("Hello World");
	}

	public int ITP1_1_B(int x){
		return x*x*x;
	}

	public void ITP1_1_C(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(a*b + " " + 2*(a+b));
	}

	public void ITP1_1_D(){
		int seconds = new Scanner(System.in).nextInt();
		System.out.println(seconds/3600 + ":" + (seconds%3600)/60 + ":" + (seconds%3600)%60);
	}

	public void ITP1_2_A(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println((a==b)?"a == b":(a > b)?"a > b":"a < b");
	}

	public void ITP1_2_B(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		System.out.println((a < b && b < c)?"Yes":"No");
	}

	public void ITP1_2_C(){
		Scanner scan = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = scan.nextInt();
		a[1] = scan.nextInt();
		a[2] = scan.nextInt();
		for(int i=0;i<a.length-1;i++){
			for(int j=i+1;j<a.length;j++){
				if(a[i] > a[j]){
					int t=a[i];a[i]=a[j];a[j]=t;
				}
			}
		}
		System.out.println(a[0] + " " + a[1] + " " + a[2]);
	}

	public void ITP1_2_D(){
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int h = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		System.out.println((x+r<=w && x-r>=0 && y+r<=h && y-r>=0)?"Yes":"No");
	}
}

Measured memory_bytes: 26324
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7;
const ll LINF=1e18;
using namespace std;
#define int long long
//template
double dp[300][300];
double frac(double h,double j,double k){
  if(h<=j&&h<=k)return (j+k)/2-h;
  else if(h>=j&&h>=k) return h-(j+k)/2;
  else if(h<j&&k<h){
    double x=j-h,y=h-k;
    return (x*x+y*y)/((x+y)*2);
  }
  else{
    double x=h-j,y=k-h;
    return (x*x+y*y)/((x+y)*2);
  }
}
//main
signed main(){
  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  for(int i=0;i<300;i++)for(int j=0;j<300;j++)dp[i][j]=INF;
  dp[0][1]=0;
  for(int i=1;i<=N;i++){
    for(int j=1;j<300;j++){
      for(int k=1;k<300;k++){
        dp[i][j]=min(dp[i][j],dp[i-1][k]+frac(v[i-1],j,k));
      }
    }
  }
  double ans=INF;
  for(int i=0;i<300;i++)ans=min(ans,dp[N][i]);
  cout<<fixed<<setprecision(12)<<ans<<endl;
}



Measured memory_bytes: 4008
#include <stdio.h>
int main(void){
    int w,a,b;
    scanf("%d%d%d",&w,&a,&b);
    if(b-(a+w)<=0&&a<=b) printf("0");
    else if(a>b) printf("%d",a-(b+w));
    else printf("%d",b-(a+w));
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A := nextInt() // takahashi physical
	B := nextInt() // talahashi attack
	C := nextInt() // aoki physical
	D := nextInt() // aoki attack

	for {
		C = C - B
		if C <= 0 {
			fmt.Print("Yes")
			break
		}
		A = A - D
		if A <= 0 {
			fmt.Print("No")
			break
		}
	}
}


Measured memory_bytes: 1756
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, p, min = 1e9, ans = 0;
  scanf("%lld", &n);
  for(i = 0; i < n; ++i) {
    scanf("%lld", &p);
    if(p < min) min = p, ans++;
  }
  printf("%lld", ans);
  return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
ll l(int n, vl &memo)
{
  if(n == 0) return 2;
  else if(n == 1) return 1;

  //memo[i] := i番目の答えを格納する, 未計算時は -1 を格納する
  if (memo[n] != -1) return memo[n];
  //メモをチェック(すでに計算済みなら答えを返す)

  return memo[n] = l(n-1, memo) + l(n-2, memo);
  //答えをメモしながら再帰呼び出し
}
int main()
{
  int n;
  cin >> n;
  vl memo(n+1, -1);
  //メモ用配列(-1は未計算であることを表す)

  cout << l(n, memo) << endl;

  return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>A(n);

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

    int l=0,r=0,xsum=0;
    long long int ans = 0;

    for(r=0;r<n;r++)
    {
        if(xsum &A[r])
        {
            while(l<r && (xsum&A[r]))
            {
                xsum ^= A[l];
                l++;
            }
            xsum^=A[r];
        }
        else
        {
            xsum^=A[r];
        }
        ans += r-l+1;
    }
    cout<<ans<<"\n";

  return 0;
}


Measured memory_bytes: 4048
import java.io.*;
import java.util.*;

public class Main {

    public void solve() {
        int w = in.nextInt(), h = in.nextInt();
        int[] a = new int[w + 1], b = new int[h];
        for (int i = 0; i < w; i++) {
            a[i] = in.nextInt();
        }
        a[w] = Integer.MAX_VALUE / 2;
        for (int i = 0; i < h; i++) {
            b[i] = in.nextInt();
        }

        Arrays.sort(a);
        Arrays.sort(b);

        long ans = 0;
        int connA = 0, connB = 0;
        int j = 0;
        for (int i = 0; i < a.length; i++) {
            while (connB < h && j < h && b[j] < a[i]) {
                connB++;
                ans += 1L * (w + 1 - connA) * b[j];
                j++;
            }

            if (connA < w) {
                connA++;
                ans += 1L * (h + 1 - connB) * a[i];
            }
        }
        out.println(ans);
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}


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

int main(){
 	int n;
    cin>>n;
    string s;
    int a=0,b=0,c=0,d=0;
    for(int i=0;i<n;i++){
   	    cin>>s;
       	if(s=="AC")
       	    a++;
       	else if(s=="WA")
           	b++;
        else if(s=="TLE")
           	c++;
       	else
       	    d++;
    }
      cout<<"AC x "<<a<<endl;
      cout<<"WA x "<<b<<endl;
      cout<<"TLE x "<<c<<endl;
      cout<<"RE x "<<d<<endl;
      
}

Measured memory_bytes: 3592
n,m = gets.split.map(&:to_i)
s = Array.new(m)
k = Array.new(m)
m.times do |i|
    k[i],*s[i] = gets.split.map(&:to_i)
end
p = gets.split.map(&:to_i)
ans = 0
(0..2**n-1).each do |i|
    f = true
    m.times do |j|
        cnt = 0
        k[j].times do |l|
            cnt ^= 1 if i[s[j][l]-1] == 1
        end
        f = false if cnt != p[j]
    end
    ans += 1 if f
end
puts ans

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

int main(void){
    int n;
    cin >> n;
    string c;
    cin >> c;
    string ans = c;
    sort(ans.begin(), ans.end());
    int cnt = 0;
    rep(i, n) if(c[i] != ans[i]) ++cnt;
    cout << cnt / 2 << endl;
    return 0;
}

Measured memory_bytes: 3852
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {

        new Main().solve();
    }

    void solve(){

        int a, b;

        Scanner sc = new Scanner(System.in);
        a = Integer.parseInt(sc.next());
        b = Integer.parseInt(sc.next());
        sc.close();

        double ataxfreemax, ataxfreemin; 
        double btaxfreemax, btaxfreemin;

        ataxfreemax = (a + 1) / 0.08;
        ataxfreemin = a / 0.08;
        btaxfreemax = (b + 1) / 0.1;
        btaxfreemin = b / 0.1;

        int amax, amin;
        if (Math.floor(ataxfreemax) == ataxfreemax){
            amax = (int) ataxfreemax - 1;
        }
        else {
            amax = (int) ataxfreemax;
        }

        if(Math.ceil(ataxfreemin) == ataxfreemin){
            amin = (int) ataxfreemin;
        }
        else{
            amin = (int) ataxfreemin + 1;
        }

        int bmax, bmin;
        if (Math.floor(btaxfreemax) == btaxfreemax){
            bmax = (int) btaxfreemax - 1;
        }
        else {
            bmax = (int) btaxfreemax;
        }

        if(Math.ceil(btaxfreemin) == btaxfreemin){
            bmin = (int) btaxfreemin;
        }
        else{
            bmin = (int) btaxfreemin + 1;
        }

        if(amax>bmax && bmax>amin){
            if(bmin>amin){
                System.out.println(bmin);
            }
            else{
                System.out.println(amin);
            }
        }
        else if(amax>bmin && bmin>amin){
            System.out.println(bmin);
        }
        else if(bmax>amax && amax>bmin){
            if(amin>bmin){
                System.out.println(amin);
            }
            else{
                System.out.println(bmin);
            }
        }
        else if(bmax>amin && amin>bmin){
            System.out.println(amin);
        }
        else{
            System.out.println("-1");
        }
    }
}

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

int n, m, l, r;
int maxL = 0;
int minR = 100000;

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    maxL = max(l, maxL);
    minR = min(r, minR);
  }
  int total = minR - maxL + 1;
  if(total < 0) cout << 0;
  else cout << total;
  cin >> n;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
 
s = 0
for i in range(N):
  s += A[i]
  s %= (10**9+7)
s = s**2
s %= (10**9+7)
 
t = 0
for i in range(N):
  t += (A[i]**2 % (10**9+7))
t %= (10**9+7)
 
ans = (s-t) % (10**9+7)
'''
tmp = (2**1000000005) % (10**9+7)
'''
tmp = 500000004
ans *= tmp
ans %= (10**9+7)
print(ans)

Measured memory_bytes: 31540
#include <stdio.h>

int main(){

int a,b,c = 0;

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

}while(a < 1 || a > 20 || b < 1 || b > 50 || c < 1 || c > 50);

int d;
d = a*b;
if(d >= c){
    printf("%d\n",c);
}else if(d < c){
    printf("%d\n",d);

}
return 0;

}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  /*
  rep(m,a[0]+1) {
    ll d[n],b[n];
    d[0]=m;
    rep(i,n) b[i]=a[i];
    b[0]-=m;
    rrep(i,n) {
      if(!i) break;
      b[i]-=d[(i+1)%n];
      d[i]=b[i];
      //d[i]=max(0LL,b[i]);
    }
    b[0]-=d[1];//d[0]+=b[1];
    PR(d,n);
    PR(b,n);
    
  }
  return;
  */
  ll l=-1,r=a[0];
  while(l+1<r) {
    ll m=(l+r)/2;
    ll d[n],b[n];
    d[0]=m;
    rep(i,n) b[i]=a[i];
    b[0]-=m;
    rrep(i,n) {
      if(!i) break;
      b[i]-=d[(i+1)%n];
      d[i]=b[i];
      //d[i]=max(0LL,b[i]);
    }
    b[0]-=d[1];
    bool f=1;
    /*
    REP(i,1,n) {
      if(b[i]<0) f=0;
    }
    */
    if(b[0]>0) f=0;
    if(!f) l=m;
    else r=m;
  }
  ll m=r;
  ll d[n],b[n];
  d[0]=m;
  rep(i,n) b[i]=a[i];
  b[0]-=m;
  rrep(i,n) {
    if(!i) break;
    b[i]-=d[(i+1)%n];
    d[i]=b[i];
    //d[i]=max(0LL,b[i]);
  }
  b[0]-=d[1];
  rep(i,n) d[i]*=2;
  PR(d,n);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3712
a,b = map(int,input().split())
s = input()
bango = ['0','1','2','3','4','5','6','7','8','9']
answer ='No'
count = 0
if s[a] == '-':
	s = s[:a]+s[a+1:]
	for i in range(len(s)):
		if s[i] in bango:
			count +=1
	if count == len(s):
		answer = 'Yes'
print(answer)

Measured memory_bytes: 3064
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];

    ll xsum = accumulate(ALL_OF(a), 0LL) / 2;
    ll aoddsum = 0;
    for (ll i = 1; i < n; i += 2) {
        aoddsum += a[i];
    }
    ll x0 = xsum - aoddsum;

    vector<ll> x(n, 0);
    x[0] = x0;
    RANGE(i, 1, n-1) {
        x[i] = a[i-1] - x[i-1];
    }
    REP(i, n) {
        cout << x[i] * 2 << " \n"[i == n-1];
    }
    
}

Measured memory_bytes: 2816
#include<iostream>
using namespace std;
int main(void){
  
  int N, M, A, B;
  
  cin >> N >> M;
  
  int count[N];
  for(int i = 0; i < N; i++){
    count[i] = 0;
  }
  
  for(int i = 0; i < M; i++){
    cin >> A >> B;
    count[A-1]++;
    count[B-1]++;
  }
  
  for(int i = 0; i < N; i++){
    cout << count[i] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

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

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> keys;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    int bit = 0;
    rep(j, b) {
      int c; cin >> c; c--;
      bit |= 1<<c;
    }
    keys.emplace_back(a, bit);
  }

  vector<int> dp(1<<n, INF);
  dp[0] = 0;
  rep(s, 1<<n) {
    rep(i, m) {
      int t = s | keys[i].second;
      chmin(dp[t], dp[s] + keys[i].first);
    }
  }

  if (dp.back() == INF) {
    cout << -1 << endl;
  } else {
    cout << dp.back() << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import fractions
A, B, C, D = map(int, input().split())
Max = B-A+1
CD = C*D//(fractions.gcd(C, D))
Ccount = B//C-A//C
Dcount = B//D-A//D
CDcount = B//CD-A//CD
if A % C == 0:
    Ccount += 1
if A % D == 0:
    Dcount += 1
if A % CD == 0:
    CDcount += 1
count = Max+CDcount-Ccount-Dcount
print(count)


Measured memory_bytes: 5048