akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Stack;
import java.util.regex.Pattern;





public class Main {

	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

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

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception r) {
					r.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception r) {
				r.printStackTrace();
			}
			return str;
		}
	}
	
	public static PrintWriter out = new PrintWriter (new BufferedOutputStream(System.out));
	static long mod = (long)(1e9+7);
	public static void main(String[] args) {
		 FastReader sc = new FastReader();
		Set<Character> set = new HashSet<>();
		char[] ch = sc.next().toCharArray();
		for(int i=0;i<ch.length;++i) set.add(ch[i]);
		if(set.size() == 2) out.println("Yes");
		else out.print("No");
		out.close();
		 
	}
	static int l,r,x,ans;
	private static void solve(int[] a, int n,List<Integer> list) {
	
		//out.println(list);
		if(list.size() == n) {
			
			long sum = 0;
			int ctr = 0,min = Integer.MAX_VALUE,max = Integer.MIN_VALUE;
			for(int i=0;i<list.size();++i) {
				ctr+=list.get(i);
				if(list.get(i) == 1) {
					sum+=a[i];
					min = Math.min(a[i], min);
					max = Math.max(a[i], max);
				}
			}
			//out.println(sum+" "+ctr+" "+max+" "+min+" "+l+" "+r+" "+x);
			if(ctr>1 && sum>=l && sum<=r && max-min>=x) {
				
				++ans;
			}
			
		}else {
		  
		   list.add(0);
		    solve(a,n,list);
		   list.remove(list.size()-1);
		   list.add(1);
		    solve(a,n,list);
		   list.remove(list.size()-1);
		 
	}
	}

}


Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;

int main() {

    string x;
    cin >> x;
    if (x[0] == x[1] && x[1] == x[2]){
    	cout << "No" << endl;
    } else {
    	cout << "Yes" << endl;
    }
} 

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

ll g(ll x) {
    //各桁に着目
    ll ans = 0;
    for (ll i = 0; i < 60; i++) {
        ll d = (1LL << i) - 1;
        ll t = x - d;
        if (t < 0) {
            break;
        }

        ll loop_width = (1LL << (i + 1));
        ll num = t / loop_width * loop_width / 2;
        num += min(t % loop_width, loop_width / 2);
        num %= 2;
        ans |= (num << i);
    }
    return ans;
}

ll f(ll A, ll B) {
    return g(A - 1) ^ g(B);
}

int main() {
    ll A, B;
    cin >> A >> B;
    cout << f(A, B) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int k, a, b;
    cin >> k >> a >> b;

    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3620
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var x = Console.ReadLine().Split().Select(int.Parse).ToList();
            Console.WriteLine(x.IndexOf(0) + 1);
        }
    }
}

Measured memory_bytes: 28268
n = int(input())
h = list(map(int, input().split()))

l = []
count = 0
for i in range(n - 1):
    if h[i] >= h[i + 1]:
        count += 1
    else:
        l.append(count)
        count = 0
l.append(count)
print(max(l))


Measured memory_bytes: 14224
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  cout << fixed << setprecision(15);

  ll N;
  cin >> N;

  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());

  const ll &ai = A.back();

  ll aj = A[0];
  for (ll i = 0; i < N - 1; i++) {
    ll a = A[i];
    if (abs(ai / 2 - aj) >= abs(ai / 2 - a)) {
      aj = a;
    }
  }

  cout << ai << " " << aj << endl;

  return 0;
}


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

void test(long& a, long b) {
  if (a > b) a = b;
}

int main() {
  int n;

  cin >> n;

  vector<long> h(n), ans(n);

  for (int i = 0; i < n; i++) {
    cin >> h[i];
    // ans[i] = 1e9;
  }

  ans[0] = 0;
  ans[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; i++) {
    ans[i] = 1e9;
    for (int j = 1; j < 2 + 1; j++) {
      // ans[i] = min(ans[i], abs(h[i] - h[i - j]) + ans[i - j]);
      test(ans[i], abs(h[i] - h[i - j]) + ans[i - j]);
      // test(ans[i], abs(h[i] - h[i - 1]) + ans[i - 1]);
      // test(ans[i], abs(h[i] - h[i - 2]) + ans[i - 2]);
    }
  }

  cout << ans[n - 1];

  return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    string S;
    cin >> N;
    int C0=0,C1=0,C2=0,C3=0;
    for (int i = 0; i < N; i++)
    {
        cin >> S;
        if (S == "AC")
        {
            C0++;
        }else if (S == "WA")
        {
            C1++;
        }else if (S == "TLE")
        {
            C2++;
        }else if (S == "RE")
        {
            C3++;
        }
    }
    cout << "AC x " << C0 << endl;
    cout << "WA x " << C1 << endl;
    cout << "TLE x " << C2 << endl;
    cout << "RE x " << C3 << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int h,w,n;
int sr,sc;
string s,t;

int main(){
	cin>>h>>w>>n;
	cin>>sr>>sc;
	sr--,sc--;
	cin>>s>>t;
	int ans=1;
	int tsr=sr,tsc=sc;
	//R
	for(int i=0;i<n;i++){
		if(s[i]=='R')sc++;
		if(sc>=w){
			ans=0;
			break;
		}
		if(t[i]=='L'&&sc!=0)sc--;
	}
	sr=tsr,sc=tsc;
	//L
	for(int i=0;i<n;i++){
		if(s[i]=='L')sc--;
		if(sc<0){
			ans=0;
			break;
		}
		if(t[i]=='R'&&sc!=w-1)sc++;
	}
	sr=tsr,sc=tsc;
	//U
	for(int i=0;i<n;i++){
		if(s[i]=='U')sr--;
		if(sr<0){
			ans=0;
			break;
		}
		if(t[i]=='D'&&sr!=h-1)sr++;
	}
	sr=tsr,sc=tsc;
	//D
	for(int i=0;i<n;i++){
		if(s[i]=='D')sr++;
		if(sr>=h){
			ans=0;
			break;
		}
		if(t[i]=='U'&&sr!=0)sr--;
	}				
	if(ans)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<string> s(n);
    rep(i,n) cin>>s[i];
    vector<map<char,int> > cnt(n);
    rep(i,n){
      rep(j,len(s[i])){
        cnt[i][s[i][j]]++;
      }
    }
    string ans;
    rep(i,26){
      char x='a'+i;
      int c=cnt[0][x];
      rep(j,n){
        if(cnt[j][x]<c){
          c=cnt[j][x];
        }
      }
      rep(i,c){
        ans.push_back(x);
      }
    }
    sort(begin(ans),end(ans));
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import os
from sys import stdin, stdout


def solve(tc):
    a, b, c, d = map(int, stdin.readline().split())

    ans = int(-1e19)
    ans = max(ans, a*c)
    ans = max(ans, b*d)
    ans = max(ans, a*d)
    ans = max(ans, b*c)
    print(ans)


tcs = 1
tc = 1
while tc <= tcs:
    solve(tc)
    tc += 1


Measured memory_bytes: 61736
/**    epsileer 18 August 2019  17:22:03  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST int t = 1; while(t--) solve()

void solve(){
    int a; cin>>a;
    string s; cin>>s;
    if(a >= 3200){
        cout<<s;
    }else{
        cout<<"red";
    }
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll INF = 1LL << 60;


int main(){
    int nums[4];
    int innums[4];
    string s;
    cin >> s;
    rep(i,4){
        nums[i] = stoi(s.substr(i,1));
        innums[i] = -nums[i];
    }
    for (int i = 0;i < 2;i++){
        for (int j = 0;j < 2;j++){
            for (int k = 0;k < 2;k++){
                int tmp = nums[0];
                if (i%2 == 0) tmp+=nums[1];
                else tmp += innums[1];
                if (j%2 == 0) tmp+=nums[2];
                else tmp += innums[2];
                if (k%2 == 0) tmp+=nums[3];
                else tmp += innums[3];

                if (tmp == 7){
                    cout << nums[0];
                    if (i%2 == 0) cout << '+' << nums[1];
                    else cout << innums[1];
                    if (j%2 == 0) cout << '+' << nums[2];
                    else cout << innums[2];
                    if (k%2 == 0) cout << '+' << nums[3];
                    else cout << innums[3];
                    cout << "=7" << endl;
                    return 0;
                } 
                
            }
        }
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

a,b = readints()
print(a*b)

Measured memory_bytes: 61712
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

LL ans = 1;

void solve(){
	if(N>=400 && N<=599) ans=8;
	else if(600<=N && N<=799) ans=7;
	else if(800<=N && N<=999) ans=6;
	else if(1000<=N && N<=1199) ans=5;
	else if(1200<=N && N<=1399) ans=4;
	else if(1400<=N && N<=1599) ans=3;
	else if(1600<=N && N<=1799) ans=2;
}

int main(){
    cin >> N;

    solve();

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

Measured memory_bytes: 3188
x, n = gets.split.map(&:to_i)
if n==0
  p x
  exit
end
p = gets.split.map(&:to_i)
if !p.include?(x)
  p x
  exit
end
100.times{|i|
  if !p.include?(x-i)
    p x-i
    exit
  end
  if !p.include?(x+i)
    p x+i
    exit
  end
}


Measured memory_bytes: 14292
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <numeric>
#include <cmath>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <cstdint>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

int solve(int t, int a, const vector<int>& h) {
    int ans = -1;
    int m = numeric_limits<int>::max();
    for (int i = 0; i < h.size(); ++i) {
        auto temp = t * 1000 - h[i] * 6;
        auto diff = abs(temp - 1000 * a);
        if (diff < m) {
            m = diff;
            ans = i + 1;
        }
    }

    return ans;
} 

int main() {
    int n;
    cin >> n;
    int t, a;
    cin >>t >> a;

    vector<int> h(n);
    for (auto&& hh : h) {
        cin >> hh;
    }

    cout << solve(t, a, h) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
int main(int argc, char* argv[]) {
    int n;
    cin >> n;
    cout << ceil(n/2.0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define il inline
#define outy printf("Yes\n")
#define outn printf("No\n")
#define outf printf("First\n")
#define outs printf("Second\n")
#define FOR(a,b,c) for(int a=b;a<=c;a++)
#define FORD(a,b,c) for(int a=b;a>=c;a--)
#define FORL(a,b) for(int a=head[b];a;a=nxt[a])
#define in(a)  a=read()
#define in2(a,b)  a=read(),b=read()
#define in3(a,b,c)  a=read(),b=read(),c=read()
#define in4(a,b,c,d)  a=read(),b=read(),c=read(),d=read()
#define inl(a)  a=readl()
#define inl2(a,b)  a=readl(),b=readl()
#define inl3(a,b,c)  a=readl(),b=readl(),c=readl()
#define inl4(a,b,c,d)  a=readl(),b=readl(),c=readl(),d=readl()
#define out(a) printf("%d\n",a)
#define out2(a,b) printf("%d %d\n",a,b)
#define out3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out4(a,b,c,d) printf("%d %d %d %d\n",a,b,c,d)
#define outl(a) printf("%lld\n",a)
#define outl2(a,b) printf("%lld %lld\n",a,b)
#define outl3(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define outl4(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define clr(x,y) memset(x,y,sizeof(x))
inline int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
inline ll readl(){
    char c;ll s=0;int t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
#define mod 1000000007
#define maxn 1
/*------------------------------------------------------------*/
//bool f[100];
int main(){
	int n;
	in(n);
	if(n/100==n%10)outy;
	 else outn; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

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

Measured memory_bytes: 256
//dp(x , y , z) : x = dishes with 1 shush , y = dishes with 2 shushi , z = dishes with 3 sushi
//dp(x , y, , z) = 1+ po*dp(x , y , z) + px*dp(x-1 , y , z) + py*dp(x+1 , y-1 , z) + pz*dp(x , y+1 , z-1)
//dp(x , y , z) = [px*dp(x-1 , y , z) + py*dp(x+1 , y-1 , z) + pz*dp(x , y+1 , z-1)]/(1-po)
//dp(0,  0, 0 ) = 0
//px = x/N , py = y/N , pz = z/N , po = (N - (x+y+z))/N
//dp(X , y, z) = (N + x*px + y*py + z*pz)/(x+y+z)
#include <bits/stdc++.h>
using namespace std;
double dp[302][302][302];
double solve(int x , int y , int z , int&n){
    if(x <0 || y<0 || z<0){
        return 0;
    }
    if(x==0 && y==0 && z==0){
        return 0;
    }
    if(dp[x][y][z] > -0.9){
        return dp[x][y][z];
    }
    double exp = n + x*solve(x-1 , y , z , n) + y*solve(x+1 , y-1 , z , n) + z*solve(x , y+1 , z-1 , n);
    return dp[x][y][z] = exp/(x+y+z);
}
int main() {
    memset(dp , -1 , sizeof(dp));
    int n;
    cin>>n;
    int x;
    int one = 0,  two=0 ,three=0;
    for(int i=1 ; i<=n ; i++){
      cin>>x;
      if(x==1){
          one++;
      }else if(x==2){
          two++;
      }else{
          three++;
      }
    }
    cout<<fixed<<setprecision(10)<<solve(one , two , three , n);
    return 0;
}


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

using namespace std;

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pi >
#define pi pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (register int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (register int var = (from); var <= ((int)to); var++)
#define DOWNTO(var, from, to) for (register int var = (from); var >= ((int)to); var--)
#define FOR(var, to)          UPTO(var, 0, (to)-1)
#define DOWN(var, from)       DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

#define MOD 1000000007
#define INF ((1 << 30)-1)
#define LINF ((1LL << 62)-1)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

struct Comb {
    vector<vector<s64> > data;
    Comb(int n) { // O(n^2)
        data = vector<vector<s64> >(n+1,vector<s64>(n+1,1));
        UPTO(i,1,n) {
            FOR(j,i+1) {
                if (!j || j == i) data[i][j] = 1;
                else data[i][j] = data[i-1][j-1] + data[i-1][j];
            }
        }
    }

    s64 ncr(int n, int r) {
        return data[n][r];
    }
};

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    int n = ri();
	int m = ri();
	cout << ((double)n)/m << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
#define vecout(v,n) for(int i=0; i<n; i++)cout<<v[i]<<" "; cout<<endl;

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int x, n = 100, ans = 0;
	cin >> x;
	while (n < x) {
		n *= 1.01;
		ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 3600
#!/usr/bin/env python3

MOD = 10 ** 9 + 7

def main():
    n, k = map(int, input().split())
    adj = [[] for i in range(n)]
    for i in range(n - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    res = k
    stack = [0]
    visited = [False for i in range(n)]
    while stack:
        i = stack.pop()
        visited[i] = True
        children = [x for x in adj[i] if not visited[x]]
        res *= perm((k - 1 if i == 0 else k - 2), len(children))
        res %= MOD
        for c in children:
            stack.append(c)
    print(res)

def perm(t, s):
    res = 1
    for i in range(s):
        res *= t
        res %= MOD
        t -= 1
    return res

if __name__ == "__main__":
    main()


Measured memory_bytes: 24432
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int a[N];
    rep(i, N) {
        cin >> a[i];
    }
    ll ans = 0;

    rep(i, N) {
        while(a[i] % 2 == 0) {
            a[i] /= 2;
            ans++;
        }
    }

    cout << ans;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int MOD = 1000000007;
int main(void){
    string s; cin>>s;
    int n = s.size();
    vector <vector<ll>> dp(n+10,vector <ll>(13));
    for(int i=0;i<n;i++){
    char c = s[i];
        if(i==0){
            if(c == '?'){
                rep(j,10) dp[0][j] = 1;
            }else{
                dp[0][c - '0'] = 1;
            }
        }else{
            if(c == '?'){
                rep(j,10) rep(k, 13)
                dp[i][(k*10 + j) % 13] += dp[i-1][k] % MOD;
            }else{
                rep(k, 13)
                dp[i][(k*10 + c - '0') % 13] += dp[i-1][k] % MOD;
            }
        }
    }
    
    cout<<dp[n-1][5]%MOD<<endl;
}


Measured memory_bytes: 13696
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
using namespace std;
int main(void)
{
  int x,a,b;
  cin>>x>>a>>b;
  if (abs(x-a)<abs(x-b))
  {
    cout<<"A";
  }
  else 
  {
    cout<<"B";
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;

char s[200002];
vector<int> p[27];
int r[200002], tr[200002];

int main(){
  scanf("%s", s + 1); int L = strlen(s + 1);
  for(int i = 1; i <= L; i++) p[s[i] & 31].push_back(i);

  int o = 0;
  for(int i = 1; i <= 26; i++){
    int z = p[i].size();
    if(z & 1){ o++; r[p[i][z / 2]] = (L + 1) / 2; }
  }

  if(o > 1){ puts("-1"); return 0; }

  for(int i = 1, z = 1; i <= L; i++){
    if(r[i] == 0){
      r[i] = z; r[p[s[i] & 31].back()] = L + 1 - z;
      z++; p[s[i] & 31].pop_back();
    }
  }

  long long ans = 0;

  for(int i = L; i >= 1; i--){
    for(int x = r[i]; x > 0; x -= x & -x) ans += tr[x];
    for(int x = r[i]; x <= L; x += x & -x) tr[x]++;
  }

  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3064
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	int n = readln.chomp.to!int;
	
	int[] ts, as;
	foreach(i; 0 .. n){
		int[] tmp = readln.chomp.split.map!(to!int).array;
		ts ~= tmp[0], as ~= tmp[1];
		}
	
	long t, a;
	t = 1, a = 1;
	
	long ad, td;
	long d;
	foreach(i; 0 .. n){
		if(t % ts[i] == 0) td = t / ts[i];
		else td = t / ts[i] + 1;
		if(a % as[i] == 0) ad = a / as[i];
		else ad = a / as[i] + 1;
		
		if(td < ad) d = ad; else d = td;
		
		t = ts[i] * d, a = as[i] * d;
		debug writeln(ts[i], ",", as[i], "; ", t, ",", a);
		}
	
	(t + a).writeln;
	
	}

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int k,s;
    cin>>k>>s;
    int ans=0;
    for(int i=0;i<=k;i++)
    {
        for(int j=0;j<=k;j++)
        {
            int ij=s-i-j;
            if(ij<=k && ij >=0)ans++;

        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define rep(i,a) for( int i = 0; i != (a); ++i )

const int INF = (1<<31)-1, MAX_N = 1<<17;

int sz, dat[2*MAX_N-1];

void init( int n_ )
{
	sz = 1;
	while( sz < n_ )
		sz <<= 1;

	rep( i, 2*sz-1 )
		dat[i] = INF;

	return;
}

void update( int k, int x )
{
	k += sz-1;
	dat[k] = x;
	while( k > 0 )
	{
		k = (k-1)>>1;
		dat[k] = std::min( dat[2*k+1], dat[2*k+2] );
	}

	return;
}

int query( int a, int b, int k, int l, int r )
{
	if( r <= a || b <= l )
		return INF;

	if( a <= l && r <= b )
		return dat[k];
	else
		return std::min( query( a, b, 2*k+1, l, (l+r)>>1 ), query( a, b, 2*k+2, (l+r)>>1, r ) );
}


int main()
{
	int n, q;
	scanf( "%d%d", &n, &q );
	
	init( n );
	
	rep( i, q )
	{
		char com[2];
		int x, y;

		scanf( "%s%d%d", com, &x, &y );

		if( com[0] == '0' )
			update( x, y );
		else
			printf( "%d\n", query( x, y+1, 0, 0, sz ) );
	}

	return 0;
}

Measured memory_bytes: 2060
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;














int main(){

      long long X,Y;
      long long s;
      vector<long long> series;


      


      cin >> X >> Y;

      s = X;

     while(1){
         if(s>Y)break;
         series.push_back(s);
         s = s*2;
     }

     cout << series.size();







 
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

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

    int N, Q;
    read(N, Q);

    MinHeap<pair<int,pii>> pq;
    rep(i, N) {
        int s, t, x;
        read(s, t, x);
        pq.emplace(x, pii(s - x, t - x));
    }

    vector<int> ans(Q, -1);

    set<pii> people;
    rep(i, Q) {
        int d; read(d);
        people.emplace(d, i);
    }

    while (!pq.empty()) {
        const int x = pq.top().first;
        const int s = pq.top().second.first;
        const int t = pq.top().second.second;
        pq.pop();
        const auto begin = people.lower_bound(pii(s, -1));
        const auto end = people.lower_bound(pii(t, -1));
        for (auto itr = begin; itr != end; ++itr) {
            const int id = itr->second;
            ans[id] = x;
        }
        people.erase(begin, end);
    }

    rep(i, Q) print(ans[i]);

    return 0;
}


Measured memory_bytes: 21356
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;
int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  int ans = 0;
  for (int i = 0; i <= n / r; i++) {
	  for (int j = 0; j <= n / g; j++) {
		  if (r * i + g * j <= n && (n - r * i - g * j) % b == 0) {
			  ans++;
			}
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

char s[128],p[128];
int l_s,l_p,count=0;

void check(int num){
	int i;
	count=0;
	for(i=0;i<l_p;i++){
		if(num==l_s){
			num=0;
		}
		if(p[i]==s[num]){
			//printf("%c\n",s[num]);
			count++;
		}else{
			break;
		}
		num++;
	}
}

int main(){
	int i,j;
	
	fgets(s,sizeof s,stdin);
	fgets(p,sizeof p,stdin);
	
	l_p=strlen(p);
	l_s=strlen(s);
	
	//\0???????????°????????????
	l_p--;
	l_s--;
	
	for(i=0;i<l_s;i++){
		if(p[0]==s[i]){
			check(i);
			if(count==l_p){
				break;
			}
		}
	}
	if(count==l_p){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
template <typename T>
void ivec(vector<T> &v, ll N){
    REP(i,0,N){ T x; cin >> x; v.push_back(x); }
}

bool ok(ll i, ll N, ll s, ll c){
    REP(j,0,N-s){
        i /= 10;
    }
    if(i%10==c){
        return true;
    }
    return false;
}

int main(){
    ll N, M;
    cin >> N >> M;
    vector<pii> SC;
    REP(i,0,M){
        ll s, c;
        cin >> s >> c;
        SC.push_back(make_pair(s, c));
    }
    ll start, end;
    if(N==1) start = 0, end = 10;
    if(N==2) start = 10, end = 100;
    if(N==3) start = 100, end = 1000;

    REP(i,start,end){
        bool pass = true;
        for(auto sc : SC){
            if(!ok(i, N, sc.first, sc.second)){
                pass = false;
                break;
            }
        }
        if(pass){
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
//-D_GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define all(x) x.begin(),x.end()
#define Max 100000+5
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f first
#define s second
#define pb push_back
int mod = 1000000007;
vector<int> g[Max];
bool vis[Max];
int d, x, y;
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
void ex(int A, int B) {
    if(B == 0) {
        d = A;
        x = 1;
        y = 0;
    }
    else {
        ex(B, A%B);
        int temp = x;
        x = y;
        y = temp - (A/B)*y;
    }
}


void dfs(int u){

	vis[u]=1;
	for(int i=0;i<g[u].size();i++){
		int v=g[u][i];
		if(vis[v]!=1)
			dfs(v);
	}
}



int power(int a,int b){
    if(b==1)return a;
    if(a>mod)a%=mod;
    int r=1;
    while(b){
        if(b&1)r=r%mod*a%mod;
        a=a%mod*a%mod;
        b/=2;
    }
    return r;
}
class uf{
    vector<int> v;
    vector<int> sz;
    
    
    public :
    uf(int n){
        v.resize(n+1);
        iota(v.begin()+1,v.end(),1);
        sz.resize(n+1,1);
        //1 to sz
    }
    int root(int b){
        while(v[b]!=b){
            b = v[b];
        }   
        return b;
    }
    void u(int a, int b){
        //combine a and b
        
        int ra=root(a);
        int rb=root(b);
        if(ra==rb)return ;
        if(sz[ra]<sz[rb]){
            v[ra] = v[rb];
            sz[rb]+=sz[ra];
        }else{
            v[rb]=v[ra];
            sz[ra]+=sz[rb];
        }
    }
    bool f(int a,int b){
        //same set
        return (root(a)==root(b));
    }
   
    
};


int32_t main(){
	IO
	int n;
  cin>>n;
  int v1 = 1000*(n/500);
  n = n%500;
  int v2 = 5*(n/5);
  cout<<v1+v2;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int n,m;
    cin >> n >> m;
    vector<int> a(n),b(m);
    frr(i,n) cin >> a[i];
    frr(i,m) cin >> b[i];
    int dp[n+1][m+1];
    ms(dp,0);
    frr(i,n+1) dp[i][0] = 1;
    frr(i,m+1) dp[0][i] = 1;

    dp[1][1] = (a[0]==b[0]) + 1;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(a[i-1]==b[j-1]){
                dp[i][j] = mod(dp[i-1][j] + dp[i][j-1],M);
            }
            else{
                dp[i][j] = mod(dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1],M);
            }
        }
    }
    cout << dp[n][m] << endl;
}

Measured memory_bytes: 31616
main = do
	n <- readLn :: IO Int
	dat <- fmap words . lines <$> getContents
	let flatten = foldr (\ a b -> a++b) []
	let count str = foldr (\b a -> if b == str then a+1 else a ) 0 (flatten dat)
	mapM (\str ->  putStrLn $ str ++ " x " ++ (show $ count str)) ["AC", "WA", "TLE", "RE"]

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  while(true) {
    long double q;
    cin >> q;
    if(q == -1) break;
    long double a = q/2.0;
    while(abs(a*a*a-q) >= 0.00001*q) {
      a = a-(a*a*a-q)/(3*a*a);
    }
    cout << fixed << setprecision(15) << a << endl;
  }
  return 0;
}

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

int main(){
  int N, a,b,c,d;
  cin >> N;
  a = N / 1000;
  N = N - 1000 * a;
  b = N / 100;
  N = N - 100 * b;
  c = N / 10;
  N = N - c * 10;
  d = N;
  if (a == b && b == c || b == c && c == d){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc=new Scanner(System.in);
		int S=sc.nextInt();
		int W=sc.nextInt();
		
		if(1<=S&&S<=100) {
			if(1<=W&&W<=100) {
				if(S<=W) {
					System.out.println("unsafe");
				}else {
					System.out.println("safe");
				}
			}
			
		}

	}

}


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

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

int main() {
    int a; cin >> a;
    string s; cin >> s;
    if(a >= 3200) {
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# https://beta.atcoder.jp/contests/arc098/tasks/arc098_a
# C - Attention

# C_Attention_beta.py

N = int(input())
S = input()

e = [0 for i in range(N)]
w = [0 for i in range(N)]

# 累積和を求める
# そこからE側の人で、Wを向くべきなのにEを向いている人
for i in range(N):
    if i > 0:
        w[i] += w[i-1]
    if i < N-1:
        if S[i] == "W":
            w[i+1] += 1
# そこからW側の人で、Eを向くべきなのにWを向いている人
for j in range(N):
    i = N-1-j
    if i < N-1:
        e[i] += e[i+1]
    if i > 0:
        if S[i] == "E":
            e[i-1] += 1

min = 10 ** 6
for i in range(N):
    total = e[i] + w[i]
    if total < min:
        min = total
print(min)


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

/*
m個選んだとき

sum(0~m-1)
sum(N-m+1~N)

 m(2N-m+1)/2 -m(m-1)/2 +1
=(m/2)(2N-2m+2) +1
=m(N-m+1) +1

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

	long long N, K;
	scanf("%lld %lld", &N, &K);

	long long result = 0;
	for (int i = K; i <= N + 1; i++) {
		result += i * (N - (long long)i + 1) + 1;
		// printf("%lld\n", result);
		result %= 1000000007;
		// if (result < 0) {
		// 	printf("%lld\n", result);
		// 	return 0;
		// }
	}

	printf("%lld", result);
	return 0;
}

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

int main() {

	int n; cin >> n;
	vector<ll> t(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum += t[i];
	}
	int m; cin >> m;
	for (int i = 0; i < m; i++) {
		int p, x; cin >> p >> x;
		ll tmpSum = sum;
		tmpSum -= t[--p];
		tmpSum += x;
		cout << tmpSum << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<stdio.h>
int main()
{
  int P,Q,R;
  scanf("%d %d %d",&P,&Q,&R);
  int A,B;
  if(P<Q)
  {
    A=P;
    if(Q<R)
      B=Q;
    else
      B=R;
  }
  else
  {
    A=Q;
    if(P<R)
      B=P;
    else
      B=R;
  }
  printf("%d",A+B);
  return 0;
}

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?b:gcd(b%a,a); }

#define ll long long int 
#define ld long double
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (200006)
ll n;
pi A[MAXN];
ll ans=LLINF;
void part1() {
	pi R=pi(LLINF, -LLINF);
	pi B=R;
	FOR(i,0,n-1) {
		R.f=min(A[i].f, R.f);
		R.s=max(A[i].f, R.s);
		B.f=min(A[i].s, B.f);
		B.s=max(A[i].s, B.s);
	}
	
	ans = min(ans, (R.s - R.f) * (B.s - B.f));
}
void part2() {
	ll maxi=-LLINF, mini=LLINF;
	FOR(i,0,n-1) maxi=max(maxi, A[i].s), mini=min(mini, A[i].f);
	vector<ll> o; 
	multiset<ll> ms;
	FOR(i,0,n-1) {
		ms.ins(A[i].f);
		o.pb(i);
	}
	sort(all(o), [&](ll x,ll y){return A[x].f<A[y].f;});
	ans = min(ans, (maxi - mini) * ((*--ms.end()) - *ms.begin()));
	FOR(i,0,n-1) {
		ms.erase(ms.find(A[o[i]].f)), ms.ins(A[o[i]].s);
		ans = min(ans, (maxi - mini) * ((*--ms.end()) - *ms.begin()));
	}
}
int main()
{
	FAST
	cin>>n;
	FOR(i,0,n-1) { cin>>A[i].f>>A[i].s; if(A[i].f > A[i].s) swap(A[i].f, A[i].s); }
	part1();
	part2();
	cout<<ans<<'\n';
}


Measured memory_bytes: 14320
module simple;import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip, core.stdc.string;

immutable long MOD = 998244353;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto E = M.iota.map!(_ => readln.split.map!(to!int).array).array;
    E.sort!"a[0] < b[0]";

    auto dp = new SegmentTree!(long, min, 1L << 59)(N);
    dp.assign(0, 0L);

    foreach (e; E) {
        auto u = e[0] - 1;
        auto v = e[1] - 1;
        auto x = e[2].to!long;
        auto a = dp.query(v, v);
        auto b = dp.query(u, v) + x;
        if (b < a) dp.assign(v, b);
    }

    auto ans = dp.query(N-1, N-1);
    if (ans == 1L << 59) {
        writeln(-1);
    } else {
        writeln(ans);
    }
}

class SegmentTree(T, alias op, T e) {
    T[] table;
    int size;
    int offset;

    this(int n) {
        size = 1;
        while (size <= n) size <<= 1;
        size <<= 1;
        table = new T[](size);
        fill(table, e);
        offset = size / 2;
    }

    void assign(int pos, T val) {
        pos += offset;
        table[pos] = val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    void add(int pos, T val) {
        pos += offset;
        table[pos] += val;
        while (pos > 1) {
            pos /= 2;
            table[pos] = op(table[pos*2], table[pos*2+1]);
        }
    }

    T query(int l, int r) {
        return query(l, r, 1, 0, offset-1);
    }

    T query(int l, int r, int i, int a, int b) {
        if (b < l || r < a) {
            return e;
        } else if (l <= a && b <= r) {
            return table[i];
        } else {
            return op(query(l, r, i*2, a, (a+b)/2), query(l, r, i*2+1, (a+b)/2+1, b));
        }
    }
}

Measured memory_bytes: 12796
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cint(n) int n;cin>>n;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int main() {
    int d;cin>>d;
    vector<int> C(26);
    vector<vector<int>> S(d,vector<int>(26));
    //vector<int> T(d);
    vector<int> CC(26,1);
    
    rep(i,26){
        cin>>C[i];
    }
    rep(i,d){
        rep(j,26){
            cin>>S[i][j];
        }
    }
    /*rep(i,d){
        cin>>T[i];
    }*/
    ll man=0;
    
    rep(i,d){
        
        P ans= MP(-inf+1,0);
        rep(kk,26){
        P hoge=MP(man,kk);
        hoge.first+=S[i][kk];
        int hogekk=CC[kk];
        rep(j,26){
            if(j==kk){
                CC[j]=0;
            }
            hoge.first-=CC[j]*C[j];
            CC[j]++;
        }
        CC[kk]=hogekk;
        ans=max(ans,hoge);
        }
        man=ans.first;
        CC[ans.second]=0;
        cout<<ans.second+1<<endl;
        //cout<<man<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vt = vector<T>;
template<class T> using vvt = vector<vt<T>>;
template<class T> using ttt = tuple<T,T>;
using tii = tuple<int,int>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define DIV ll(1e9+7)
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
//const double PI = M_PI;  
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}
// IT 5000兆　欲しい
/* Coding space */
int main(){
  int n; cin >> n;
  vi in(n+1);
  int max_value = -1;
  int max_index = -1;
  rep(i,n){
    cin >> in[i];
    if(in[i] >= max_value){
      max_value = in[i];
      max_index = i;
    }
  }
  int ans = INF;
  int ans_index = 0;
  rep(i,n){
    if(i == max_index) continue;
    if(ans > abs(in[i] - max_value/2)){
      ans = abs(in[i] - max_value/2);
      ans_index = i;
    }
  }
  cout << max_value << " " << in[ans_index] << endl;
}

Measured memory_bytes: 640