akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner (System.in);
		
		int [] pasta = new int [3];
		int [] juice = new int [2];
		
		int i, j;
		
		int sum = 0;
		int min = 9999;
		
		for (i = 0; i < 3; i++) {
			pasta[i] = sc.nextInt();
		}
		
		for (i = 0; i < 2; i++) {
			juice[i] = sc.nextInt();
		}
		
		for (i = 0; i < 3; i++) {
			for (j = 0; j < 2; j++) {
				sum = pasta[i] + juice[j] - 50;
				if (sum < min) {
					min = sum;
				}
			}
		}
		
		System.out.println(min);
		
	}

}

Measured memory_bytes: 17324
A,B,K=map(int,input().split())
def cookie(A,B):
    if A%2==1:
        A-=1
    B+=A//2
    A=A//2
    return A,B
for i in range(K//2):
    A,B=cookie(A,B)
    B,A=cookie(B,A)
if K%2==1:
    A,B=cookie(A,B)
print(A,B)

Measured memory_bytes: 3060
n, k = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
h = Hash.new(0)
l = r = 0
li = ri = -1
zero, min = k, nil
while true
    if 1 <= r && r <= k
        h[r] += 1
        zero -= 1 if h[r] == 1
    end
    if 1 <= l && l <= k
        h[l] -= 1
        zero += 1 if h[l] == 0
    end
    if zero == 0
        min = ri - li if min.nil? || min > ri - li
        li += 1
        break if li == ri
        l, r = arr[li], 0
    else
        ri += 1
        break if ri == n
        l, r = 0, arr[ri]
    end
end
puts (min.nil? ? 0 : min)


Measured memory_bytes: 19164
#include "bits/stdc++.h"
using namespace std;
#define fastcin {\
    cin.tie(0);\
    ios::sync_with_stdio(false);\
}
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i >= b; i--)
#define fore(i, a) for(auto &i:a)
#define print(x) cout << x << "\n"
#define SORT(a, n) sort(a, a+n);
#define REVERSE(a,n) reverse(a,a+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VREVERSE(v) reverse(v.begin(), v.end());
#define MOD 1000000007
#define yes "YES"
#define no "NO"
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main() {
    fastcin;
    ll a, b, ans;
    cin >> a >> b;
    ans = a+b;
    if(a*b > ans) ans = a * b;
    if((a-b)> ans) ans = a - b;
    print(ans);
    return 0;
}

Measured memory_bytes: 256
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;
    string s; cin >> s;

    vi r(n), b(n), g(n);

    r[0]=(s[0]=='R' ? 1 : 0);
    b[0]=(s[0]=='B' ? 1 : 0);
    g[0]=(s[0]=='G' ? 1 : 0);

    rep (i, 1, n-1) {
        r[i] = r[i-1];
        b[i] = b[i-1];
        g[i] = g[i-1];
        if (s[i]=='R') r[i]++;
        if (s[i]=='B') b[i]++;
        if (s[i]=='G') g[i]++;
    }

    ll ans = 0;
    rep (i, 0, n-1) {
        rep (j, i+1, n-1) {
            if (s[i]==s[j]) continue;

            string a = "ab"; a[0] = s[i];  a[1] = s[j];
            sort(a.begin(), a.end());
            if (a=="BR") {
                int dis = j - i;
                int ct = g[n-1] - g[j];
                if (j + dis < n && s[j+dis]=='G') ct--;
                ans += (ll)ct;
            } else if (a=="GR") {
                int dis = j - i;
                int ct = b[n-1] - b[j];
               // db2(dis, ct);
                if (j + dis < n && s[j+dis]=='B') ct--;
                ans += (ll)ct;
            } else if (a=="BG") {
                int dis = j - i;
                int ct = r[n-1] - r[j];
                if (j + dis < n && s[j+dis]=='R') ct--;
                ans += (ll)ct;
            }
        }
    }

    cout << ans;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3660
# encoding: utf-8
N, K = map(int, input().split())
D = list(map(int, input().split()))

Db = []
for Di in range(10):
    if Di not in D: Db.append(Di)
# print("#", Db)

for level in range(6):
    if N // (10 ** level) < 1: break
# print("#", level)
    
# memo = [None] * ((level + 1) * 10000)
    
def pay(pos, tmp):
    # print("##", pos, tmp)
    if pos > level or tmp >= N:
        if tmp >= N:
            # print("###", tmp)
            return tmp
        else: return 10000
    # elif memo[pos * 10000 + tmp] != None: return memo[pos * 10000 + tmp]
    rets = []
    for Dbi in Db:
        add = Dbi * (10 ** pos)
        rets.append(pay(pos + 1, tmp + add))
    ret = min(rets)
    # if memo[pos * 10000 + tmp] == None: memo[pos * 10000 + tmp] = ret    
    return ret

print(pay(0, 0))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
   
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=1;i<=n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>

const int N = 502;
int dis[N][N];
int a[N][N];

signed main()
{
    int n;
    cin >> n;
    
    f(i,n) f(j,n) dis[i][j] = min(i-1,j-1);
    f(i,n) f(j,n) dis[i][j] = min(dis[i][j],min(n-i,n-j));
    f(i,n) f(j,n) a[i][j] = 1;
    
    int x;
    long long int res = 0;
    
    f(i,n*n)
    {
        cin >> x;
        
        int v1 = (x-1)/n + 1;
        int v2 = x - (n*((x-1)/n));
        
        res+=dis[v1][v2];
        a[v1][v2] = 0;
        
        queue<pii> q;
        q.push({v1,v2});
        
        while(!q.empty())
        {
            auto x = q.front(); q.pop();
            
            if(x.F > 1 && dis[x.F-1][x.S] > a[x.F][x.S] + dis[x.F][x.S])
            {
                dis[x.F-1][x.S] = a[x.F][x.S] + dis[x.F][x.S];
                q.push({x.F-1,x.S});
            }
             
            if(x.F < n && dis[x.F+1][x.S] > a[x.F][x.S] + dis[x.F][x.S])
            {
                dis[x.F+1][x.S] = a[x.F][x.S] + dis[x.F][x.S];
                q.push({x.F+1,x.S});
            }
                           
            if(x.S > 1 && dis[x.F][x.S-1] > a[x.F][x.S] + dis[x.F][x.S])
            {
                dis[x.F][x.S-1] = a[x.F][x.S] + dis[x.F][x.S];
                q.push({x.F,x.S-1});
            }
                           
            if(x.S < n && dis[x.F][x.S+1] > a[x.F][x.S] + dis[x.F][x.S])
            {
                dis[x.F][x.S+1] = a[x.F][x.S] + dis[x.F][x.S];
                q.push({x.F,x.S+1});
            }                   
        }
        
    }
    
    cout << res;
    
}

Measured memory_bytes: 5536
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

template<typename Monoid>
struct SlidingWindowAggregation {
    using F = function< Monoid(Monoid, Monoid) >;

    stack< Monoid > front,back;
    stack< Monoid > sum_front;
    Monoid sum_back;
    const F f;
    const Monoid M1;
    SlidingWindowAggregation (const F f, const Monoid &M1) : f(f), M1(M1) {
        sum_front.push(M1);
        sum_back = M1;
    }

    void push(Monoid x) {
        back.push(x);
        sum_back = f(sum_back, x);
    }

    void pop() {
        if(front.empty()) {
            while(! back.empty()) {
                front.push(back.top());
                sum_front.push(f(front.top(), sum_front.top()));
                back.pop();
            }
            sum_back = M1;
        }
        assert(! front.empty());
        front.pop();
        sum_front.pop();
    }

    Monoid accumulate() const {
        return f(sum_front.top(), sum_back);
    }
    
    bool empty() const {
        return front.empty() && back.empty();
    }

    size_t size() const {
        return front.size() + back.size();
    }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n,x; cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = INF;
    auto f = [&](ll a, ll b){return min(a, b);};
    rep(k, n){
        ll tmp = 0;
        SlidingWindowAggregation<ll> swag(f, INF);
        for(int i = (n - k) ; i < n; i++)swag.push(a[i % n]);
        rep(i,n){
            swag.push(a[i]);
            tmp += swag.accumulate();
            swag.pop();
        }
        // debug(tmp);
        tmp += x * k;
        chmin(ans, tmp);
    }

    cout << ans << endl;
}

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

typedef long long int ll;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll h,w;cin>>h>>w;
	ll i,j;int grid[1009][1009],ans[1009][1009];
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				char ch;
				cin>>ch;
				if(ch=='.')
				grid[i][j]=0;
				else
				grid[i][j]=1;
			}
		}
		ll mo=1e9+7;
		ans[0][0]=1;
		for(i=0;i<h;i++)
		{
			for(j=0;j<w;j++)
			{
				if(i==0 && j==0)
				continue;
				ans[i][j]=0;
				if(grid[i][j]==1)
				continue;
				
				if(i-1>=0)
				ans[i][j]+=ans[i-1][j];
				if(j-1>=0)
				ans[i][j]+=ans[i][j-1];
				ans[i][j]%=mo;	
				//cout<<ans[i][j]<<" ";	
			}
			//cout<<endl;
		}
		cout<<ans[h-1][w-1];
}


Measured memory_bytes: 8192
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.nio.file.Files;
import java.nio.charset.StandardCharsets;
//给出两个数a,b 求出[a,b]中各位数字之和能整除原数的数的个数。
public class Main {

    int mod ;
    //
    void solve(int v, int[] arr) {
        Arrays.sort(arr);
        int max = 0;
        int n = arr.length;
        max = arr[n-1];
        Set<Integer> set = new HashSet<>();

        boolean[] dup = new boolean[max+1];
        int[] cnt = new int[max+1];
        for(int i=0;i<n;i++){
            cnt[arr[i]]++;
        }
        for(int i=0;i<n;i++){
            if(!dup[arr[i]]){
                for(int j=2;j*arr[i]<=max;j++){
                    dup[j*arr[i]] = true;
                }
            }
        }
        int res = 0;
        for(int i=0;i<n;i++){
            if(!dup[arr[i]]&&cnt[arr[i]]==1){
                res++;
            }
        }

        System.out.println(res);
    }


    public static void main(String[] args)  throws IOException {
        // Use the Scanner class

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[]  s = br.readLine().split(" ");
        Main test = new Main();

        int n = Integer.parseInt(s[0]);

        int[] arr = new int[n];
        s = br.readLine().split(" ");
        for(int i=0;i<n;i++) {
           arr[i] = Integer.parseInt(s[i]);

        }

        test.solve(n, arr);
        //int tot = Integer.parseInt(br.readLine());


//        int i =1;
//        System.out.println();
//        while(tot>0){
//
//            String s = br.readLine();
//            String[] sr = s.split(" ");
//            List<Long> ls = new ArrayList<>();
//            for(String ss:sr){
//                ls.add(Long.parseLong(ss));
//            }
//            Main tt = new Main();
//            tt.sol(ls);
//            // String Buffer to store answer
//            StringBuffer sb = new StringBuffer();
////            Solution obj = new Solution();
////
////            System.out.println("Case #"+i+": "+obj.sol());
//            tot--;
//            i++;
//        }
    }

}


Measured memory_bytes: 63916
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;


int main(){
  string s,t;
  cin >> s >> t;

  int sSize,tSize,count,cmpCount;
  sSize = s.size();
  tSize = t.size();
  count = 0;
  cmpCount = 0;
  for (int i=0;i<sSize - tSize+1;i++){
    string newS = s.substr(i,tSize);
    //cout << newS << endl;
    count = 0;
    for (int j=0;j<tSize;j++){
      
      if (newS.substr(j,1) == t.substr(j,1)){
        //cout << newS.substr(j,1) << t.substr(j,1) << endl;
        count += 1;
      }
    }
    cmpCount = max(cmpCount,count);
    //cout << cmpCount << endl;

  }
  
  cout << tSize - cmpCount << endl;
  return 0;
}

Measured memory_bytes: 3636
// 

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int R;
    double pinum = 3.14159265;
    cin >> R;
    cout << 2.0 * pinum * R << endl;
    return 0;
}


Measured memory_bytes: 3776
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n; cin >> n;
	string s, t;
	cin >> s >> t;
	REP(i, n){
		cout << s[i] << t[i];
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

int main() {
	int N, M;
	cin >> N;
	vector<int> D(N);
	rep(i,N) cin >> D[i];
	cin >> M;
	vector<int> T(M);
	rep(i,M) cin >> T[i];
	sort(all(D));
	sort(all(T));

	bool f = true;
	int j = 0;
	rep(i,M) {
		for(;j < N; j++) {
			if(T[i] == D[j]) {
				j++;
				break;
			}
			else if(T[i] < D[j]) {
				f = false;
			}
			else if(j == N-1) {
				f = false;
			}
		}
	}
	if(f) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
def main(N, A, B, C):
    tot = 0
    for i in range(N):
        fab = A[i] == B[i]
        fac = A[i] == C[i]
        fbc = B[i] == C[i]
        if fab and fac:
            continue
        elif fab or fac or fbc:
            tot += 1
        else:
            tot += 2
    print(tot)

if __name__ == "__main__":
    N = int(input())
    A = input()
    B = input()
    C = input()
    main(N, A, B, C)

Measured memory_bytes: 3064
#include<iostream>
#include <bits/stdc++.h>
#include<algorithm>
#include <cstring>
#define endl "\n"
#define SRK ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define EPS 1e-6
typedef long long ll;
using namespace std;

bool check9(string s)
{
    int res = 0,i;
    for (i = 0; i < s.length(); i++)
    {
        res = (res * 10 + s[i] - '0') % 9;
    }
    if (res == 0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    SRK;
    ll n,i;
    unsigned long long int count = 0;
    cin >> n;
    ll arr[n],maxi = 0,idx = 0;
    for (i = 0; i < n; i++)
    {
        cin >> arr[i];
        if (arr[i] > maxi)
        {
            maxi = arr[i];
            idx = i;
        }
    }
    for (i = 1; i < idx; i++)
    {
        if (arr[i] < arr[i-1])
        {
            int x = (arr[i - 1] - arr[i]);
            count += (arr[i - 1] - arr[i]);
            arr[i] += x;
        }
    }
    for (i = idx + 1; i < n; i++)
    {
        count += (maxi - arr[i]);
    }
    //count = 999999999*199999;
    cout << count << endl;
}


Measured memory_bytes: 5088
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int n = 1, d[100000] = {};
int abc = 0, arc = 0, ans = 0;

int main() {

	
	ll a, b, c, d, lcm;
	ll s, t;
	cin >> a >> b >> c >> d;
	lcm = (c * d) / gcd(c, d);

	s = b - (b / c + b / d - b / lcm);
	a--;
	t = a - (a / c + a / d - a / lcm);

	cout << s - t << endl;


}

Measured memory_bytes: 256
while True:
    H,W = map(int,raw_input().split())
    if (H,W) == (0,0):
        break
    for k in range(H):
        if k%2==0 and W%2==0:
            print "#."*(W/2)
        elif k%2==0 and W%2==1:
            print "#."*(W/2)+"#"
        elif k%2==1 and W%2==0:
            print ".#"*(W/2)
        elif k%2==1 and W%2==1:
            print ".#"*(W/2)+"."
    print ""

Measured memory_bytes: 4220
import java.util.*;

public class Main {
    private static Scanner scr;
	public static void main(String args[]){
	    scr = new Scanner(System.in);
		String[] str = scr.nextLine().split(" ",0);;
		int l = Integer.parseInt(str[0]);
		int h = Integer.parseInt(str[1]);
		System.out.println( (l*h) + " " + ((l+h)*2) );
        
	}
}

Measured memory_bytes: 26028
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int mod=1e9+7;
int n,m,K,f[4005][2005][2],sum[4005];
int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
void upd(int &a,int b){a=(a+b>=mod)?a+b-mod:a+b;}
int main(){
	scanf("%d%d%d",&n,&m,&K);
	int tot=(n+m-1)/(K-1);
	f[0][0][0]=1;
	m--;K--;
	int ans=0;
	for(int i=1;i<=tot;i++){
		for(int p=1;p<=n+1;p++) sum[p]=add(sum[p-1],add(f[i-1][p-1][0],f[i-1][p-1][1]));
		for(int p=0;p<=n;p++){
			f[i][p][0]=add(sum[p+1],mod-sum[p]);
			int k=max(0,p-K);
			f[i][p][1]=add(sum[p],mod-sum[k]);
		}
		for(int p=n%K;p<=n;p+=K){
			if(i*K-p<=m) upd(ans,f[i][p][1]);
		}
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;

int n, a[max_n];
multiset<int> q;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        q.insert(a[i]);
    }
    int mx = 1 << 30;
    int ans = 0;
    while (mx > 1) {
        int cnt = 0;
        while (!q.empty()) {
            int x = *q.rbegin();
            if (x < mx / 2) {
                break;
            }
            q.erase(q.find(x));
            if (x == mx / 2) {
                ++cnt;
                continue;
            }
            auto it2 = q.find(mx - x);
            if (it2 != q.end()) {
                q.erase(it2);
                ++ans;
            }
        }
        mx /= 2;
        ans += cnt / 2;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 10368
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,X;
	cin>>N>>X;
	vector<int> M(N);
	for(int i=0;i<N;++i){
		cin>>M[i];
		X-=M[i];
	}
	sort(M.begin(),M.end());
	
	int ans = N + X/M[0];
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var day int
	fmt.Scan(&day)

	switch day {
	case 25:
		fmt.Println("Christmas")
	case 24:
		fmt.Println("Christmas Eve")
	case 23:
		fmt.Println("Christmas Eve Eve")
	case 22:
		fmt.Println("Christmas Eve Eve Eve")
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N;
  vector<string> blue(N);
  vector<int> blueNum(N);
  for(int i=0;i<N;i++){
    cin>>blue.at(i);
    for(int j=0;j<N;j++){
      if(blue.at(i)==blue.at(j))blueNum.at(i)+=1;
    }
  }
  cin>>M;
  vector<string> red(M);
  
  for(int i=0;i<M;i++){
    cin>>red.at(i);
     
  }
  
  int saidaichi=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      if(blue.at(i)==red.at(j))blueNum.at(i)-=1;
    }
    if(i==0 || blueNum.at(i)>=saidaichi)saidaichi= blueNum.at(i);
  }
  if(saidaichi<0)saidaichi=0;
  cout<<saidaichi<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int ll;
typedef pair<int, int> P;

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

  int n, m;
  cin >> n;

  map<string, int> nn;
  vector<string> v(n);

  rep(i, n) {
    string a;
    cin >> a;
    v[i] = a;
    nn[a]++;
  }

  cin >> m;
  map<string, int> mm;

  rep(i, m) {
    string a;
    cin >> a;
    mm[a]++;
  }
  int res = 0;
  rep(i, n) {
    res = max(nn[v[i]] - mm[v[i]], res);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int A, B, C, X;

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> A >> B >> C >> X;

  ll ans = 0;
  for (int i = 0; i <= A; i++) {
    if (500 * i == X) {
      ans++;
      continue;
    }
    for (int j = 0; j <= B; j++) {
      if (500 * i + 100 * j == X) {
        ans++;
        break;
      }
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) {
          ans++;
          break;
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
while True:
    n, p = map(int, raw_input().split())
    if n == 0:
        break

    cnt = [0] * n
    wan = p
    pos = 0

    while True:
        if wan:
            cnt[pos] += 1
            wan -= 1

            if wan == 0 and cnt[pos] == p:
                print pos
                break
        else:
            wan = cnt[pos]
            cnt[pos] = 0
        pos = (pos + 1) % n

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

int main(){
    string a;
    cin >> a;
    if(a[0] == a[1] || a[1] == a[2] || a[0] == a[2]){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

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

#define MOD 1000000007
#define MAX 100002

int n;

vector<long long int> v;

long long int way[MAX];

long long int ppow(long long int i,long long int j){
	long long int res=1;
	while(j){
		if(j&1LL)res*=i;
		if(res>=MOD)res%=MOD;
		j>>=1LL;
		i*=i;
		if(i>=MOD)i%=MOD;
	}
	return res;
}
long long int rng(int l,int r){
	if(l>r)return 0;
	long long int ret=way[r];
	if(l)ret+=MOD-way[l-1];
	ret%=MOD;
	return ret;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		int a;
		scanf("%d",&a);
		v.push_back(a);
	}
	long long int ans2=1;
	for(int i=1;i<=n;i++){
		ans2*=i;
		ans2%=MOD;
	}
	for(int i=1;i<=v.size();i++){
		way[i]=ans2*ppow(i,MOD-2);
		if(way[i]>=MOD)way[i]%=MOD;
		if(i)way[i]+=way[i-1];
		if(way[i]>=MOD)way[i]%=MOD;
	}
	long long int A=0;
	for(int i=0;i<n;i++){
		long long int ans=rng(1,i+1)+rng(2,n-i);
		if(ans>=MOD)ans%=MOD;
		A+=ans*v[i];
		if(A>=MOD)A%=MOD;
	}
	printf("%lld\n",A);
	return 0;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a,b;
    cin>>a>>b;
    if(a=='H'&&b=='H')cout<<"H\n";
    else if(a=='H'&&b=='D')cout<<"D\n";
    else if(a=='D'&&b=='H')cout<<"D\n";
    else cout<<"H\n";
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 10005
int rank[MAX]={0};
int p[MAX];
int n;

void makeset(int tmp){
	while(tmp--){
		p[tmp]=tmp;
	}
}

int find(int tmp){
	if(tmp!=p[tmp])p[tmp]=find(p[tmp]);
	return p[tmp]; 
}

void unite(int x,int y){
	int tmpx,tmpy;
	tmpx = find(x);
	tmpy = find(y);
	if(tmpx==tmpy)return;
	if(rank[tmpx]>rank[tmpy]){
		p[tmpy]=tmpx;
	}else{
		p[tmpx]=tmpy;
		if(tmpx==tmpy)
		++rank[tmpy];
	}
}
bool same(int x,int y){
	return find(x)==find(y);
}
int main(){
	int x,y,com,q;
	cin>>n>>q;
	makeset(n);
	while(q--){
		cin>>com;
		if(1==com){
			cin>>x>>y;
			if(same(x,y))cout<<1<<endl;
			else cout<<0<<endl;
		}else{
			cin>>x>>y;
			unite(x,y);
		}
	}
}


Measured memory_bytes: 3156
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


int t, n;
int main() {
	REP(i, 4) {
		int ans = 0;
		cin >> t >> n;
		if (t == 1)ans += 6000 * n;
		if (t == 2)ans += 4000 * n;
		if (t == 3)ans += 3000 * n;
		if (t == 4)ans += 2000 * n;
		cout << ans << endl;
	}
}


Measured memory_bytes: 3084
parseint(x) = parse(Int, x)
parseintmap(x::Array{SubString{String},1}) = map(parseint, x)

function main()
    N = parseint(readline())
    a = []
    for i in 1:N
        s, p = readline() |> split
        p = parseint(p)
        append!(a, [(s, -p, i)])
    end
    sort!(a)
    for x in a
        println(x[3])
    end
end

main()


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

int main()
{

  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (int i = 0; i < M; i++)
  {
    int a, b;
    cin >> a >> b;
    A[a - 1] += 1;
    A[b - 1] += 1;
  }
  for (int i = 0; i < N; i++)
  {
    cout << A[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int A, B, C, X;
	cin >> A >> B >> C >> X;
	int cnt = 0;
	for (int i = 0;i < A + 1;++i) {
		for (int j = 0;j < B + 1;++j) {
			for (int k = 0;k < C + 1;++k) {
				int sum = 500 * i + 100 * j + 50 * k;
				if (sum == X) {
					++cnt;
				}
			}
		}
	}
	cout << cnt  << endl;


	return 0;
}

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

int main(){
 int a,b,c,sum;
  cin >> a ;
  cin >> b;
  cin >> c;
  sum = a*100 + b*10+ c;
  if(sum%4 == 0) {
  	cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

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

	a := make([]int, n)

	var tmp int

	for i := 0; i < n-1; i++ {
		fmt.Scan(&tmp)
		a[tmp-1]++
	}

	for _, v := range a {
		fmt.Println(v)
	}

}


Measured memory_bytes: 6460
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d.sort(reverse=True)
t.sort(reverse=True)

for i in range(n):
    if t[-1]==d[-1]:
        d.pop()
        t.pop()
    else:
        d.pop()
    if t==[]:
        print("YES")
        exit()
    if d==[]:
        print("NO")
        exit()

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

using ll = long long;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
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 int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

ll pow_mod(ll n, ll p, ll mod) {
    if (p == 0) {
        return 1;
    } else if (p % 2 == 1) {
        return pow_mod(n, p - 1, mod) * n % mod;
    } else {
        ll s = pow_mod(n, p / 2, mod);
        return s * s % mod;
    }
}

void solve() {
    int n;
    cin >> n;
    vector<int> d(n);
    int x;
    cin >> x;
    if (x != 0) {
        cout << 0 << EOL;
        return;
    }
    d[0] = 1;
    REP(i, n - 1) {
        cin >> x;
        if (x >= n || x <= 0) {
            cout << 0 << EOL;
            return;
        }
        d[x]++;
    }
    ll ans = 1;
    REP(i, n - 1) {
        if (d[i + 1] == 0) {
            FOR(j, i + 1, n) {
                if (d[j] != 0) {
                    cout << 0 << EOL;
                    return;
                }
            }
            break;
        }

        ans *= pow_mod(d[i], d[i + 1], 998244353);
        ans %= 998244353;
    }
    cout << ans << endl;

}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <unordered_map>
#include <iomanip>
using namespace std;


int main(){
    int n, k;
    cin >> n >> k;
    double result = 0;
    for (int i = 1; i <= min(n, k - 1); i++){
        result += pow(0.5, ceil(log2(1.0 * k / i)));
    }
    result += max(n - k + 1, 0);
    cout << setprecision(20) << result * 1.0 / n << endl;
    return 0;
}

Measured memory_bytes: 384
from bisect import bisect_left
from bisect import bisect_right


N = int(input())
L = list(map(int, input().split()))
L.sort()

"""
短いほうから２本固定して条件に合うものをさがす（長いほうから２本固定でもOK）
最長と最短を固定するとややこしくなるから、こういう場合は最長/最短どちらかから固定するほうがいいか
"""


ans = 0
for i in range(N-2):
    #a = L[i]

    for j in range(i+1, N-1):
        #b = L[j]
        # そもそもcがaやbより大きいので、下の解法のようにilを求める必要などなく、il=で考えれば良かったんや！
        # 下のbisectでlo=~を指定すると遅くなりTLE。内部でL[j:]のlistを新たに生成して、そこにbisectしてるっぽく、list生成するので遅い
        #k = bisect_left(L, a+L[j])
        k = bisect_left(L, L[i]+L[j])
        ans += k - j - 1



"""
ans = 0
for i in range(N):
    for j in range(i+1, N):
        l = L[j] - L[i]
        r = L[j] + L[i]
        #  a < b < c（場合によっては等号を含む）で考えたときの、b - a < cを満たすもの 
        il = bisect_right(L, l, lo=j)
        #  a < b < c（場合によっては等号を含む）で考えたときの、c < a + bを満たすもの
        ir = bisect_left(L, r, lo=j)
        # b - a < cを満たすものがない場合、飛ばす
        if il == N-1:
            break
        
        ans += ir - il - 1
"""

print(ans)


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N,M; //problems submit
    cin >> N >> M;
    vector<bool> acd(N,false);
    vector<int> pena(N,0);

    int ok,penalty;
    ok = 0 , penalty = 0;
    
    REP(i,M){
        int problem;
        string result;
        cin >> problem >> result;
        if(acd[problem-1])continue;

        if(result=="WA"){
            pena[problem-1]++;
        }else{
            acd[problem-1] = true;
            ok++;
            penalty += pena[problem-1];
        }
    }
    cout << ok << " " << penalty << endl;

}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int N = scan.nextInt();
			int M = scan.nextInt();
			int[]L = new int[M];
			int[]R = new int[M];
			
			for(int i = 0;i<M;i++) {
				L[i] = scan.nextInt();
				R[i] = scan.nextInt();
			}
			
			int left = 1;
			int right = N;
			
			for(int i =0;i<M;i++) {
				if(left<L[i]) {
					left = L[i];
				}
				
				if(right>R[i]) {
					right = R[i];
				}
				
				
			}
			
			
			System.out.println(right-left>=0?right-left+1:0);
			
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 83536
#!/bin/bash
li="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"
input=`cat /dev/stdin`
echo "${li}" |cut -d' ' -f $input

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

int main(){
	int n;
  	cin >> n;
  	vector<int> l(n);
  	rep(i, n) cin >> l[i];
  
  	sort(l.begin(), l.end());
  	int ans = 0;
	rep(b, n){
    	rep(a, b){
        	int ab = l[a] + l[b];
          	int right = lower_bound(l.begin(), l.end(), ab) - l.begin();
          	int left = b+1;
          	ans += (right - left);
        }
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 3640
n = int(input())
data = {}
max_poll = 1

for i in range(n):
    s = input()
    try:
        data[s] += 1
    except:
        data[s] = 1
    if max_poll < data[s]:
        max_poll = data[s]

winner = []
for key, value in data.items():
    if max_poll == value:
        winner.append(key)

winner.sort()
for i in winner:
    print(i)


Measured memory_bytes: 32096
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

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

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;cin>>n;cout<<n*(n%2+1)<<endl;

	return 0;
}


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

int D,N;
int main()
{
    cin>>D>>N;
    if(N==100)
    {
        
        cout<<(int)(pow(100,(double)D))*(N+1)<<endl;
    }
    else
    {
        cout<<(int)(pow(100,(double)D))*N<<endl;
    }
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
	int i,j,n;
	int a,b;
	char x[5][5];
	for(i = 0; i <= 2; i++)
	{
		scanf("%s", x[i]);
	}
	printf("%c%c%c\n",x[0][0],x[1][1],x[2][2]);
	return 0;
}

Measured memory_bytes: 128
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())

n = I()
A = readInts()
ans = []
SUM = 0
for i in range(n):
    SUM ^=A[i]
for i in range(n):
    ans.append(SUM^A[i])
print(*ans)


Measured memory_bytes: 32808
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define int long long
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef pair <int, int> pr;
const int N = 1e5 + 5, mod = 1e9 + 7;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
pr p[N];
int n, m, tot, cnt, ans, a[N], b[N], s[N], f[N], tr[N];
bool cmp(pr x, pr y) {return x.fi == y.fi ? x.se > y.se : x.fi < y.fi;}
void add(int x, int y) {while(x <= tot) (tr[x] += y) %= mod, x += x & (-x);}
int query(int x) {int res = 0; while(x) (res += tr[x]) %= mod, x -= x & (-x); return res;}
signed main() {
	n = read(); m = read();
	for(int i = 1; i <= n; ++ i) a[i] = read();
	for(int i = 1; i <= m; ++ i) b[i] = read();
	for(int i = 1; i <= n; ++ i) {
		if(a[i] <= b[1] || a[i] >= b[m]) continue;
		int x = lower_bound(b + 1, b + m + 1, a[i]) - b;
		if(a[i] == b[x]) continue;
		p[++ cnt] = mp(a[i] - b[x - 1], s[++ tot] = b[x] - a[i]);
	}
	sort(s + 1, s + tot + 1); tot = unique(s + 1, s + tot + 1) - s - 1;
	for(int i = 1; i <= cnt; ++ i) p[i].se = lower_bound(s + 1, s + tot + 1, p[i].se) - s;
	sort(p + 1, p + cnt + 1, cmp); cnt = unique(p + 1, p + cnt + 1) - p - 1;
	f[0] = 1;
	for(int i = 1; i <= cnt; ++ i) f[i] = query(p[i].se - 1) + 1, add(p[i].se, f[i]);
	for(int i = 0; i <= cnt; ++ i) (ans += f[i]) %= mod;
	printf("%lld\n", ans);
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n;

int main() {
	cin >> n;
	cout << n*(n+1)/2 << ln;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (input) {
    //??\????????????????????????????????????
    var inputArray = input.split(' ');
    //??\?????????????????°????????????
    var num = inputArray.map(function(x){
        return parseInt(x);
    });
    //????????????[W,H,x,y,r]
    var W = num[0];
    var H = num[1];
    var x = num[2];
    var y = num[3];
    var r = num[4];
    var answer = 'Yes';
    if((x+r) > W){
        answer = 'No';
    }
    else if((x-r) < 0){
        answer = 'No';
    }
    else if((y+r) > H){
        answer = 'No';
    }
    else if((y-r) < 0){
        answer = 'No';
    }
    console.log(answer);
});

Measured memory_bytes: 15672
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++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; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
#define fs first
#define sc second

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


int to[60][200100];

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n){
        cin >> to[0][i];
        // to[i][j] jから2^i個先
        to[0][i]--;
    }
    rep(i, 59){
        rep(j, n){
            to[i + 1][j] = to[i][to[i][j]];
        }
    }
    int v = 0;
    for(int i = 59; i >= 0; --i){
        ll l = 1LL << i;
        if (l <= k){
            v = to[i][v];
            k -= l;
        }
    }
    print(v + 1);


}

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

int main() {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d", max(a * b, max(a + b, a - b)));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
 
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define mod 1000000007
    #define qmod 998244353
    #define M 1000001
    #define endl "\n"
    #define all(a) (a).begin(),(a).end()
    #define rep(i,a,b) for(int i=a;i<b;++i)
    #define repr(i,a,b) for(int i=a;i>=b;--i)
    #define F first
    #define S second
    #define pb push_back
    #define mp make_pair
 
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef vector<int> vi;
    typedef vector<string> vs;
    typedef vector<pii> vii;
    typedef vector<vi> vvi; 

    int main(){
        
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin); 
    freopen("output.txt","w",stdout);   
    #endif  */
 
        fast;
        int n;
        cin>>n;
        int a[n],mi=101,mx=0;
        rep(i,0,n) {
            cin>>a[i];
            mi=min(mi,a[i]);
            mx=max(mx,a[i]);
        }
        int ans=INT_MAX;
        rep(i,mi,mx+1){
            int p=0;
            rep(j,0,n) p+=pow((a[j]-i),2);
            ans=min(p,ans);
        }
        cout<<ans;
        return 0;  
    } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int main() {
	int n; cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
		for (int j = i; j <= n; j += i)
			ans += j;
	cout << ans << "\n";
}

Measured memory_bytes: 3624
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
        
        Console.WriteLine(input.OrderBy(i=>-i).ToArray()[0]- input.OrderBy(i => i).ToArray()[0]);


        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法
 
        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();

    }
}

Measured memory_bytes: 13396
#include<stdio.h>
int main(){
    long n,a,b;
    long sum;
    long x,amari;
    long flag = 0;
    
    scanf("%ld %ld %ld",&n,&a,&b);
    sum = a+b;
    
    x = n/sum;
    amari = n % sum;
    
    if(sum >= n && n <= a) printf("%ld\n",n);
    else if(sum >= n && n > a) printf("%ld\n",a);
    else flag = 1; //ans = a*x;
    
    if(amari > a && flag == 1) printf("%ld\n",(a*x)+a);
    else if(amari <= a && flag == 1) printf("%ld\n",(a*x)+amari);
    else
        
    return 0;
}


Measured memory_bytes: 128