akhauriyash/Code-Regression huggingface dataset:
s=list(input())
n=len(s)+1
f=1
s.append('!')
y=[]
for i in range(n-1):
    if s[i]==s[i+1]:
        f+=1
    else:
        y.append(f)
        f=1
if len(y)==1:
    print(y[0]*(y[0]+1)//2)
    exit()
if s[0]=='<':
    ans=0
    for i in range(len(y)-1):
        ans+=y[i]*(y[i]-1)//2
        if i%2==0:
            ans+=max(y[i],y[i+1])
    if len(y)%2==0:
        ans+=y[-1]*(y[-1]-1)//2
    else:
        ans+=y[-1]*(y[-1]+1)//2
    print(ans)
else:
    ans=0
    for i in range(len(y)-1):
        if i==0:
            ans+=y[i]*(y[i]+1)//2
            continue
        ans+=y[i]*(y[i]-1)//2
        if i%2==1:
            ans+=max(y[i],y[i+1])
    if len(y)%2==0:
        ans+=y[-1]*(y[-1]+1)//2
    else:
        ans+=y[-1]*(y[-1]-1)//2
    print(ans)


Measured memory_bytes: 9776
////////////////////////////////////////////    _LeMur_
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <chrono>
#include <random>
#include <bitset>
#include <cstdio>
#include <vector>
#include <string>
#include <ctime>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>

using namespace std;

const int N = 200005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

string s;

int main(){
	mt19937 myrand(chrono::steady_clock::now().time_since_epoch().count());
    cin >> s;
    int answ = 1;
    bool flag = false;
    bool t = false;
    for(int i=1;i<(int)s.size();i++){
        if(flag){
            flag = false;
            t = true;
            continue;
        }
        if(t){
            ++answ;
            t = false;
            continue;
        }
        if(s[i] == s[i - 1]){
            ++answ;
            flag = true;
            continue;
        }
        ++answ;
    }
    if(flag) --answ;
    cout << answ << endl;
    return 0;
}


Measured memory_bytes: 1336
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
    int N, X;
    cin >> N >> X;
    int m[N];
    int tmp = pow(10, 5);
    for (int i = 0; i < N; i++)
    {
        cin >> m[i];
        X -= m[i];
        tmp = min(tmp, m[i]);
    }
    int ans = N;
    ans += X/tmp;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let n = scan.next::<i32>();
    let mut max:i64 = -1000000;
    let mut min:i64 = 1000000;
    let mut sum:i64 = 0;
    for _ in 0..n {
        let a:i64 = scan.next();
        if max < a { max = a; }
        if min > a { min = a; }
        sum += a;
    }
    writeln!(out, "{} {} {}", min, max, sum).ok();
}



Measured memory_bytes: 5044
#include<bits/stdc++.h>
using namespace std;
char s[1000];
int main()
{
    scanf("%s",s);
    int len = strlen(s);
    int m=(1<<(len-1));
    long long ans=0,t;
 
    for(int i=0;i<m;i++){
        t=s[0]-'0';
        for(int j=0;j<len;j++){
            if(j==len-1||i&1<<j){
                ans+=t;
                t=0;
                if(j==len-1)  break;
            }
            t*=10;
            t+=s[j+1]-'0';
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long int INF = 1e9;

int dp[20010][260];
int c[20], x[20010];

int main() {
    int n, m;

    while (true)
    {
        cin >> n >> m;
        if(n + m == 0) break;
        for(int i = 0; i < m; i++) cin >> c[i];
        for(int i = 0; i < n; i++) cin >> x[i];
        for(int i = 0; i < n+1; i++)
        {
            for (int j = 0; j < 257; j++)
            {
                dp[i][j] = INF;
            }
        }
        dp[0][128] = 0;

        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < 256; j++)
            {
                for (int k = 0; k < m; k++)
                {
                    int ne = j + c[k];
                    ne = max(ne, 0);
                    ne = min(ne, 255);
                    dp[i+1][ne] = min(dp[i+1][ne], dp[i][j] + (x[i] - ne) * (x[i] - ne));
                }
            }
        }

        int ans = INF;
        for (int i = 0; i < 256; i++)
        {
            ans = min(ans, dp[n][i]);
        }

        cout << ans << endl;
    }

}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int x;
  cin >> x;
  if (x < 100) {
    cout << 0 << '\n';
    return 0;
  }

  int cnt = x / 100;
  cout << (x % 100 <= 5 * cnt) << '\n';
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct tree {
	string name;
	int depth;
	vector<unique_ptr<tree>>childs;
	tree(const string _name,const int _depth) :name(_name),depth(_depth),childs() {

	}
};
unique_ptr<tree> maketree(vector<string>&sts, vector<int>&ns,int depth,int &a) {
	unique_ptr<tree> t(std::make_unique<tree>(sts[a],depth));
	while (a+1!=sts.size()&&ns[a+1] > depth) {
		a++;
		t->childs.push_back(maketree(sts, ns, depth + 1, a));
		
	}
	return t;
}

vector<string> split(const string &str, char delim) {
	vector<string> res;
	size_t current = 0, found;
	while ((found = str.find_first_of(delim, current)) != string::npos) {
		res.push_back(string(str, current, found - current));
		current = found + 1;
	}
	res.push_back(string(str, current, str.size() - current));
	return res;
}
int dfs(const unique_ptr<tree>&tp,int type,string a,string b,bool flag) {
	//a is parant of b
	if (type == 0) {
		if (a == tp->name) {
			for (auto&& c : tp->childs) {
				if (c->name == b)return 1;
			}
			return 0;
		}
		else {
			for (auto &&c : tp->childs) {
				int num=dfs(c, type, a, b,flag);
				if (num != -1)return num;
			}
			return -1;
		}
	}
	else if (type == 1) {
		if (flag) {
			if (tp->name == b)return 1;
			for (auto &&c : tp->childs) {
				int num = dfs(c, type, a, b, flag);
				if (num != -1)return num;
			}
			return -1;
		}
		else {
			if (tp->name == a)flag = true;
			for (auto &&c : tp->childs) {
				int num = dfs(c, type, a, b, flag);
				if (num != -1)return num;
			}
			if (flag)return 0;
			else return -1;
		}
	}
	else {
		int same = 0;
		for (auto&&c : tp->childs) {
			if (c->name == a)same++;
			if (c->name == b)same++;
			int num = dfs(c, type, a, b, flag);
			if (num != -1)return num;
		}
		if (same == 2)return 1;
		else if (same == 1)return 0;
		else return -1;
	}
}

int main() {
	while (1) {

		int N, M; cin >> N >> M;
		if (!N)break;
		unique_ptr<tree> t;
		{
			vector<string>sts;
			vector<int>ns;
			string st; getline(cin, st);
			for (int i = 0; i < N; ++i) {
				getline(cin, st);
				int n = st.find_first_not_of(' ');
				sts.push_back(st.substr(n));
				ns.push_back(n);
			}

			int a = 0;
			t = maketree(sts, ns, 0, a);
		}
		
		while (M--) {
			string st;
			getline(cin, st);
			vector<string>sts(split(st, ' '));
			string a = sts[0];
			string b = sts[5].substr(0, sts[5].size() - 1);
			int ans;
			if (sts[3] == "child") {
				ans = dfs(t, 0, b, a, false);
			}
			else if (sts[3] == "ancestor") {
				ans = dfs(t,1, a, b, false);
			}
			else if (sts[3] == "sibling") {
				ans = dfs(t, 2, a, b, false);
			}
			else if (sts[3] == "parent") {
				ans = dfs(t, 0, a, b, false);
			}
			else if (sts[3] == "descendant") {
				ans = dfs(t, 1, b, a, false);
			}
			if (ans == 1)cout << "True" << endl;
			else if (ans == 0)cout << "False" << endl;
			else assert(false);
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a,b;
  cin >> a >> b;
  int c=stoi(a+b);
  double d=c;
  if(fmod(sqrt(d),1)==0)cout << "Yes";
  else cout << "No";
  cout << endl;
}
/*#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b;
  if(b<10)c=10*a+b;
  else if(a<100)c=100*a+b;
  else c=1000*a+b;
  for(int i=0;i<10000;i++){
    if(i*i==c){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";
  return 0;
}*/


Measured memory_bytes: 256
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

ll sz,ctr[26];
string s;
ll ret;

int main(){
    cin >> s;
    sz = s.size();
    for (auto c: s) ctr[c-'a']++;
    ret = sz*(sz-1)/2;
    REP(i,26) ret -= ctr[i]*(ctr[i]-1)/2;
    cout << ret+1 <<endl;
}


Measured memory_bytes: 640
function howMuch(items, item, s) {
  try{
  var
  recipe, price = items[item].price,
  sum, flag = false, j;
  s = s || [];
//  console.log(item, s);
  if(recipe = items[item].recipe) {
    s.push(item);
    sum = 0; flag  = true;
    for(j = 0; j < recipe.length; j++) {
      if(s.indexOf(recipe[j]) !== -1 || !(recipe[j] in items)) {
        flag = false;
        break;
      }
      sum += howMuch(items, recipe[j], s);
    }
    if(flag) {
      price = min(price, sum);
    }
    s.pop();
  }
  }catch(e){throw [e,items,item];}
  
  return price;
}

function min(x, y) {
  return x < y ? x : y;
}

function main() {
  var
  i, n, m, line,
  len = input.length,
  items;
  for(i = 0; i < len;) {
    items = {};
    n = parseInt(input[i++], 10) + i;
    if(n === i) break;
    for(; i < n; i++) {
      line = input[i].split(' ');
      items[line[0]] = {price: parseInt(line[1], 10)};
    }
    m = parseInt(input[i++], 10) + i;
    for(; i < m; i++) {
      line = input[i].split(' ');
      items[line[0]].recipe = line.slice(2);
    }
//    console.log(items);
    console.log(howMuch(items, input[i++]));
  }
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main();
});

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
using namespace std;
int main() {
	int n,h[100000]; cin >> n;
	for (int i = 0; i < n; ++i) cin >> h[i];
	int x=h[0],m = 0,cnt=0;
	for (int i = 1; i < n; ++i) {
		if (h[i] <= x) 
			++cnt;
		else 
			cnt = 0;
		x = h[i];
		m = max(m, cnt);
	}
	cout << m << endl;
	return 0;
}

Measured memory_bytes: 640
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    string N; cin >> N;

    string ans = N[0] == N[2] ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
ll mod=998244353;
vecll perm;
ll pw(ll a,ll p){
    if(p==0)return 1;
    if(p%2==0){
        ll d=pw(a,p/2);
        return d*d%mod;
    }
    return a*pw(a,p-1)%mod;
}
ll divide(ll a,ll b){
    return a*(ll)pw(b,mod-2)%mod;
}
ll n;
ll comb(ll a,ll b){
    return divide(perm[a],perm[b]*perm[a-b]%mod);
}
int main(){
    n=in();ll a=in(),b=in(),k=lin(),ans=0;
    perm=vecll(n+1);
    perm[0]=1;
    rep2(i,1,n){
        perm[i]=perm[i-1]*i%mod;
    }
    ll x=0;
    while(a*x<=k&x<=n){
        if((k-x*a)%b==0){
            ll y=(k-x*a)/b;
            if(0<=y&y<=n)ans=(ans+comb(n,x)*comb(n,y)%mod)%mod;
        }
        x++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  ll N;
  string ans;

  cin >> N;
  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }

  ll p = 1;
  while (N) {
    ll np = p*(-2);
    if (N % np == 0) {
      ans += "0";
    } else {
      ans += "1";
      N -= p;
    }
    p = np;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
def tenth(a):
  temp = a
  while True:
    if temp % 10 == 0:
      return temp
    else:
      temp += 1

li = list()
ans = 0

for i in range(5):
  li.append(int(input()))
  ans += tenth(li[i])
  li[i] = tenth(li[i]) - li[i]
  
ans -= max(li)

print(ans)



Measured memory_bytes: 2940
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
const int D=998244353;
const int MAXN=500233;
int n,m,ans;
int fac[MAXN],inv[MAXN],N[MAXN],M[MAXN];

int qpow(int x,int y) {
	int ret=1;
	while(y) {
		if(y&1) ret=1ll*ret*x%D;
		x=1ll*x*x%D;
		y>>=1;
	}
	return ret;
}

void first(int lim) {
	fac[0]=1;
	for(int i=1;i<=lim;i++) fac[i]=1ll*fac[i-1]*i%D;
	inv[lim]=qpow(fac[lim],D-2);
	for(int i=lim-1;~i;i--) inv[i]=1ll*inv[i+1]*(i+1)%D;

	N[0]=M[0]=1;
	for(int i=1;i<=lim;i++) N[i]=1ll*N[i-1]*(n+1)%D;
	for(int i=1;i<=lim;i++) M[i]=1ll*M[i-1]*(m+1)%D;
}
int C(int x,int y) {
	return 1ll*fac[x]*inv[y]%D*inv[x-y]%D;
}

int main() {
	scanf("%d%d",&n,&m);
	if(n>m) swap(n,m);
	first(m);
	for(int i=0,val;i<=n;i++) {
		val=1ll*C(n,i)*C(m,i)%D*fac[i]%D*M[n-i]%D*N[m-i]%D;
		if(i&1) ans=(ans+D-val)%D;
		else ans=(ans+val)%D;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 11564
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val nk   = inputs(0).split(" ").map(_.toInt)
  val n    = nk(0)
  val k    = nk(1)
  val aSeq = inputs(1).split(" ").map(_.toInt)

  solve(n, k, aSeq)

  def solve(n: Int, k: Int, aSeq: Seq[Int]): Unit = {
    (0 until n - k).foreach { i =>
      if(aSeq(i) < aSeq(i + k)) {
        println("Yes")
      } else {
        println("No")
      }
    }

  }
}

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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >

const int N=7e5+5;
int cnt[N];
vector<int> adj[N];
int n,m;
bool visited[N];
void dfs(int u ){

if(visited[u])
    return;

    visited[u]=1;
    int cur=1;
    for(auto x:adj[u]){
        if(!visited[x]){
            dfs(x);
        cur+=cnt[x];
        }
    }
    cnt[u]=cur;
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        adj[y].push_back(x);
        adj[x].push_back(y);
    }
    int ans=-1e9;
    for(int i=1;i<=n;i++){
        dfs(i);
        ans=max(ans,cnt[i]);

    }
    cout<<ans;

}


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

using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;

  int needToAddLeft = 0;
  int leftCount = 0;
  for (int i = 0; i < N; i++) {
    if (S[i] == '(') {
      leftCount++;
    } else if (S[i] == ')') {
      if (leftCount == 0) {
        needToAddLeft++;
      } else {
        leftCount--;
      }
    }
  }
  for (int i = 0; i < needToAddLeft; i++) S = '(' + S;
  for (int i = 0; i < leftCount; i++) S = S + ')';

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
dp = [0]*90
dp[0] = 2
dp[1] = 1
for i in range(2, 90):
    dp[i] = dp[i-1]+dp[i-2]

print(dp[N])

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

#define ll long long
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define INF (ll)1e9
#define fora(i,a,b) for(ll i=a;i<b;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
#define mli map<ll,int>
#define mll map<ll,ll>

using namespace std;

int main()
{   ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    string s;
    cin>>n;
    ll c1=0,c2=0,c3=0,c4=0;
    fora(i,0,n)
    {
        cin>>s;
        if(s=="AC")
        c1++;
        else if(s=="WA")
        c2++;
        else if(s=="TLE")
        c3++;
        else
        {
            c4++;
        }
        
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl<<"TLE x "<<c3<<endl<<"RE x "<<c4<<endl;
    
    return 0;
}




Measured memory_bytes: 3644
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  string s[] = {"Sunny", "Cloudy", "Rainy"};
  map<string, string> mp;
  mp[s[0]] = s[1];
  mp[s[1]] = s[2];
  mp[s[2]] = s[0];
  string tmp;
  cin >> tmp;
  cout << mp[tmp];
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

signed main(){
	int n, m;
	scanf("%d %d", &n, &m);
	vector<ll> x(n), y(n), z(n);
	for(int i = 0; i < n; i++){
		scanf("%lld %lld %lld", &x[i], &y[i], &z[i]);
	}
	ll ans = 0;
	for(int bit = 0; bit < (1 << 3); bit++){
		ll ans1 = 0;
		bool x1 = (bit & (1 << 0)), x2 = (bit & (1 << 1)), x3 = (bit & (1 << 2));
		vector<ll> data(n, 0);
		for(int i = 0; i < n; i++){
			if(x1) data[i] += x[i];
			else data[i] -= x[i];
			if(x2) data[i] += y[i];
			else data[i] -= y[i];
			if(x3) data[i] += z[i];
			else data[i] -= z[i];
		}
		sort(data.begin(), data.end(), greater<ll>());
		for(int i = 0; i < m; i++){
			ans1 += data[i];
		}
		ans = max(ans, ans1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define uii             unordered_map<int,int>
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
void S_K_S()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int32_t main()
{
	S_K_S();
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	int x;
	cin>>x;
	if(x==0)
		cout<<1;
	if(x==1)
		cout<<0;
}


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

int n;
char ls[52];
string s, ans;

void solve(char c, int x);

int main() {
  int i;
  for(i = 0; i < 52; ++i) {
    if(i < 26)
      ls[i] = 'a' + i;
    else
      ls[i] = 'A' + i % 26;
  }
  while(1) {
    cin >> n;
    if(n == 0) break;
    vector<int> v;
    for(i = 0; i < n; ++i) {
      int x;
      cin >> x;
      v.push_back(x);
    }
    cin >> s;
    for(i = 0; i < s.size(); ++i) solve(s[i], v[i % v.size()]);
    cout << ans << endl;
    ans = "";
  }
  return 0;
}

void solve(char c, int x) {
  int now;
  if(c >= 'a' && c <= 'z')
    now = c - 'a';
  else
    now = c - 'A' + 26;
  ans += ls[(now - x + 52) % 52];
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define SZ(a) (int)((a).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef pair <int, int> Pii;
typedef pair <ll, int> Pli;
typedef unsigned long long ull;
const double eps = 1e-8;
const int mod = (int)(1e9) + 7;
const int inf = 0x7fffffff;
const int N = (int)(2e5) + 7;

ll x, k, d;

int main() {

    // freopen("in.in", "r", stdin);
    scanf("%lld%lld%lld", &x, &k, &d);
    x = abs(x);
    if (x % d) {
        if (k < (x + d - 1) / d) printf("%lld\n", x - k * d);
        else {
            ll d1 = x % d, d2 = (d - x % d) % d;
            k -= (x + d - 1) / d;
            if (k & 1) printf("%lld\n", d1);
            else printf("%lld\n", d2);
        }
    } else {
        if (k <= x / d) printf("%lld\n", x - k * d);
        else {
            k -= x / d;
            if (k & 1) printf("%lld\n", d);
            else puts("0");
        }
    }

    return 0;
}

Measured memory_bytes: 3824
#include<stdio.h>

int linersearch(int A[], int n, int key){
    int i=0;
    
    A[n]=key;
    while(A[i]!=key) i++;
    
    return i!=n;
}

int main(){
    int i,n,A[10001],q,key,sum=0;
    
    scanf("%d", &n);
    for(i=0;i<n;i++) scanf("%d", &A[i]);
    
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d", &key);
        if(linersearch(A,n,key)) sum++;
    }
    printf("%d\n",sum);
    
    return 0;
}


Measured memory_bytes: 2088
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll isPrime[1000010]={0};
vector<ll> Prime;

void sieve(){
	ll i,j;
	isPrime[0] = isPrime[1] = 1;
	for( i=2; i<1000010; i++)if(isPrime[i]==0)for(j=2*i; j<1000010; j+=i)isPrime[j]=1;
	for( i=1; i<1000010; i++)if(isPrime[i]==0)Prime.push_back(i);
}
ll modMul(ll a,ll b,ll mod){
	ll res=0;
	if(mod<=MOD){
        return ((a%mod)*(b%mod))%mod;
	}
	while(b){
		if(b&1)res = (res+a)%mod;
		a = (2*a)%mod;
		b = b/2;
	}
	return res;
}
ll modPow(ll x,ll n,ll mod){
	ll r = 1;
	while(n){
		if(n&1)r = modMul(r,x,mod);
		x = modMul(x,x,mod);
		n = (n>>1);
	}
	return r;
}
vector<int>v;
void printDivisors(int n) 
{ 
    // Vector to store half of the divisors 3343434 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i==0) 
        { 
            if (n/i == i) // check if divisors are equal 
                if (i%2!=0){
                	v.push_back(i);
				} 
            else
            { 
                if (i%2!=0){
                	v.push_back(i);
				}  
  
                // push the second divisor in the vector 
                if ((n/i)%2!=0){
                	v.push_back(n/i);
				} 
            } 
        } 
    } 
  
    // The vector will be printed in reverse 
} 
int sum=0;
int dp[3001][3001];
 string lcs(string x,string y,int n,int m){
	for (int i=0;i<=n;i++){
		for (int j=0;j<=m;j++){
			if (i==0||j==0){
				dp[i][j]=0;
			}
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			if (x[i-1]==y[j-1]){
				dp[i][j]=1+dp[i-1][j-1];
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
  int i=n;
	int j=m;
	string s="";
  while(1){
		if (i==0 || j==0){
			break;
		}
			if (x[i-1]==y[j-1]){
				s+=x[i-1];
				i=i-1;
				j=j-1;
			}
			else{
				if (dp[i][j]==dp[i-1][j]){
					i=i-1;
				}
				else{
					j=j-1;
				}
			}
		}
  return s;
}
   


void solve (){
	string x,y;
	cin>>x>>y;
	//memset(dp,-1,sizeof(dp));
   int n=x.length();
  int m=y.length();
	string q=lcs(x,y,n,m);
	//cout<<dp[x.length()][y.length()];
	//ring q=fun(x,y);
  if (q.length()==0){
    cout<<' ';
  }
  else{
    for (int i=q.length()-1;i>=0;i--){
      cout<<q[i];
    }
  }
}
	
	

int main(){
	int t;
	//cin>>t;
	t=1;
	while(t--){
		solve();
		}
		
	}


Measured memory_bytes: 38896
def main3():
    N, A, B = map(int, input().split())
    
    d = B - A
    if d % 2 == 0:
        print(d // 2)
    else:
        print(min(((d + 1) // 2 + N - B ), ((d + 1) // 2 + A - 1)))
         
if __name__ == "__main__":
    main3()

Measured memory_bytes: 9056
# -*- coding: utf-8 -*-

import numpy as np

N, K = map(int, input().split())
 
h = np.array(list(map(int, input().split())))
 
dp = np.zeros(N)
 
for n in range(1, N):
    k = min(K, n)
    temp = np.min(dp[n-k:n] + np.abs(h[n]-h[n-k:n]))
    dp[n] = temp
print(int(dp[-1]))

Measured memory_bytes: 22812
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 4050
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int r;
    cin>>r;
    double ans=(double)2*r*3.141592;
    printf("%.8lf\n",ans);
    return 0;
}

Measured memory_bytes: 3760
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int n;
	cin >> n;
	vector<int> R(n), mins(n);
	int min_so_far = INT_MAX;
	for(int i = 0; i < n; i++){
		cin >> R[i];
		if(R[i] < min_so_far){
			min_so_far = R[i];
		}
		mins[i] = min_so_far;
	}
	int ans = INT_MIN;
	for(int i = n - 1; i >= 1; i--){
		ans = max(ans, R[i] - mins[i - 1]);
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 4332
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &x,T b){if(x<b){x=b;return true;}return false;}
template<typename T> bool chmin(T &x,T b){if(x>b){x=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

const int MAX=2e6+1; //nCrのnのMAX+1
ll fac[MAX],finv[MAX],inv[MAX],sinv[MAX];

void cominit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  sinv[0]=0,sinv[1]=1;
  for (int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
    sinv[i]=(sinv[i-1]+inv[i]%mod)%mod;
  }
}
ll com(int n,int k){ //1≦k≦n≦10^7
  if (n<k) return 0;
  if (n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}
//Add cominit(); in main function.

int main(){
  cominit();
  int n; cin >> n;
  vector<ll> x(n);
  rep(i,n) cin >> x[i];
  ll ans=0;
  rep(i,n-1){
    ans+=fac[n-1]*(x[i+1]-x[i])%mod*sinv[i+1]%mod;
    ans%=mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 66584
def solve():
    mod = 10**9+7
    n, k = map(int, input().split())
    m = min(n-1,k)
    ans = 1
    dp0 = [1]*(m+1)
    dp1 = [1]*(m+1)
    for i in range(1,m+1):
        dp0[i] = dp0[i-1]*(n-i+1)*pow(i,mod-2,mod)%mod
        dp1[i] = dp1[i-1]*(n-i)*pow(i,mod-2,mod)%mod
        ans += dp0[i]*dp1[i]%mod
        ans %= mod
    return ans
print(solve())


Measured memory_bytes: 24576
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <uint32_t Modulus>
class modular {
public:
  using value_type = uint32_t;
  using max_type = uint64_t;

  static constexpr value_type mod = Modulus;
  static constexpr value_type mod_min = 1;
  static constexpr value_type mod_max = 2147483647;
  static_assert(mod >= mod_min, "invalid mod :: too small");
  static_assert(mod <= mod_max, "invalid mod :: too big");

  template <class T>
  static constexpr value_type normalize(T value_) {
    if (value_ < 0) {
      value_ = -value_;
      value_ %= mod;
      if (value_ == 0) return 0;
      return mod - value_;
    }
    return value_ % mod;
  }

private:
  value_type value;

public:
  constexpr modular(): value(0) { }
  template <class T>
  explicit constexpr modular(T value_): value(normalize(value_)) { }
  template <class T>
  explicit constexpr operator T() { return static_cast<T>(value); }

  constexpr value_type operator () () const { return value; }
  constexpr modular operator - () const { return modular(mod - value); }
  constexpr modular operator ~ () const { return inverse(); }

  constexpr value_type &extract() { return value; }
  constexpr modular inverse() const { return power(mod - 2); }
  constexpr modular power(max_type exp) const {
    modular res(1), mult(*this);
    while (exp > 0) {
      if (exp & 1) res *= mult;
      mult *= mult;
      exp >>= 1;
    }
    return res;
  }

  constexpr modular operator + (const modular &rhs) const { return modular(*this) += rhs; }
  constexpr modular& operator += (const modular &rhs) { 
    if ((value += rhs.value) >= mod) value -= mod; 
    return *this; 
  }

  constexpr modular operator - (const modular &rhs) const { return modular(*this) -= rhs; }
  constexpr modular& operator -= (const modular &rhs) { 
    if ((value += mod - rhs.value) >= mod) value -= mod; 
    return *this; 
  }

  constexpr modular operator * (const modular &rhs) const { return modular(*this) *= rhs; }
  constexpr modular& operator *= (const modular &rhs) { 
    value = (max_type) value * rhs.value % mod;
    return *this;
  }

  constexpr modular operator / (const modular &rhs) const { return modular(*this) /= rhs; }
  constexpr modular& operator /= (const modular &rhs) { return (*this) *= rhs.inverse(); }

  constexpr bool zero() const { return value == 0; }
  constexpr bool operator == (const modular &rhs) const { return value == rhs.value; }
  constexpr bool operator != (const modular &rhs) const { return value != rhs.value; }
  friend std::ostream& operator << (std::ostream &stream, const modular &rhs) {
    return stream << rhs.value;
  }

};

using modint = modular<1000000007>;

int main() {
  int N, H, D;
  std::cin >> N >> H >> D;
  std::vector<modint> dp(H);
  modint coeff, fact(1);
  for (int i = 1; i <= N; ++i) {
    fact *= modint(i);
    coeff += fact;
  }
  std::fill(dp.begin(), dp.begin() + D, fact);
  modint sum;
  for (int i = 1; i < H; ++i) {
    sum += dp[i - 1];
    if (i - D - 1 >= 0) {
      sum -= dp[i - D - 1];
    }
    dp[i] += sum * coeff;
  }
  std::cout << dp.back() << '\n';
}


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

int main(){
    string s;
    cin >> s;
    
    for(int bit=0; bit<(1<<4);bit++){
        string t;
        t += s[0];
        int sum = s[0] - '0';
        for(int i=1; i<4;i++){
            if((bit>>i)&1){
                t += "+";
                sum += s[i] - '0';
            }else{
                t += "-";
                sum -= s[i] - '0';
            }
            t += s[i];
        }
        if(sum == 7){
            cout << t << "=7" << endl;
            return 0;
        }
    }
    
}


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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int s = max({a,b,c});
    int r  = 3*s - (a+b+c);
    if(r%2 == 0)cout << r/2 << endl;
    else cout << (r+1)/2+1;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SYOU(x) fixed<<setprecision(x) //小数点桁数を指定する
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    INT(n);
    INT(k);
    VEC(int,p,n);
    sort(p.begin(),p.end());
    ll ans = 0LL;

    for(int i = 0; i < k;  ++i){
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3696
#include<stdio.h>

#define N 2000000
#define K 10000

void countingSort(int *, int *, int);

int A[N+1], B[N+1];

int main()
{
  int i, n;

  scanf("%d", &n);
  for(i=1; i<=n; i++)
    {
      scanf("%d", &A[i]);
    }

  countingSort(A, B, n);

  for(i=1; i<=n; i++)
    {
      printf("%d", B[i]);
      if(i+1<=n) printf(" ");
    }
  printf("\n");
  
  return 0;
}

void countingSort(int *A, int *B, int n)
{
  int i, j;
  int C[K+1];

  for(i=0; i<=K; i++) C[i] = 0;

  for(j=1; j<=n; j++) C[A[j]]++;

  for(i=1; i<=K; i++) C[i] = C[i]+C[i-1];

  for(j=n; j>=1; j--)
    {
      B[C[A[j]]] = A[j];
      C[A[j]]--;
    }
}

Measured memory_bytes: 16264
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n,i,count=0;
   cin>>n;
   int a[n],a1[n];
   for(i=0;i<n;i++)
   {
       cin>>a[i];
       a1[i]=a[i];
   }
   sort(a,a+n);
   for(i=0;i<n;i++)
   {
       if(a[i]!=a1[i])
       {
           count++;
       }
   }
   if(count==2 || count==0)
   {
       cout<<"YES";
   }
   else{
    cout<<"NO";
   }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=400&&n<=599){
        cout<<"8"<<endl;
    }
    else if(n>=600&&n<=799){
        cout<<"7"<<endl;
    }
    else if(n>=800&&n<=999){
        cout<<"6"<<endl;
    }
    else if(n>=1000&&n<=1199){
        cout<<"5"<<endl;
    }
    else if(n>=1200&&n<=1399){
        cout<<"4"<<endl;
    }
    else if(n>=1400&&n<=1599){
       cout<<"3"<<endl;
    }
    else if(n>=1600&&n<=1799){
        cout<<"2"<<endl;
    }
    else cout<<"1"<<endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define Rep(i, N) for(int i = 0; i < N; i++)

signed main()
{
  int N;
  string S;
  
  int acnt, ucnt;
  bool flag = true;

  acnt = ucnt = 0;
  
  cin >> N;

  Rep(i, N) {
    cin >> S;
    
    if(S == "A") {
      acnt++;
    } else if(S == "Un") {
      ucnt++;
    }
    
    if(ucnt > acnt) flag = false;
  }

  if(acnt != ucnt) flag = false;
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> N(4); cin >> N[0] >> N[1] >> N[2] >> N[3];
  sort(N.begin(), N.end());
  cout << ((N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    if (K == 0) {
        cout << (ll)N * N << endl;
        return 0;
    }
    REP(b, 1, N) {
        int p = N/b;
        int r = N % b;
        ans += p * max(0, b - K);
        ans += max(0, r - K + 1);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define ll long long
#define vi vector<int>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

int N, K, A[100005], max_v = 0;

int GCM(int a, int b){
    if(b==0) return a;

    return GCM(b, a % b);
}

bool solve(){
    rep(i, N)
        max_v = max(max_v, A[i]);

    int gcm = A[0];

    for(int i = 1; i < N; i++){
        gcm = GCM(gcm, A[i]);
    }

    if(K % gcm == 0 && K <= max_v) return true;
    else return false;
}

int main(){
    cin >> N >> K;

    rep(i,N)
        cin >> A[i];

    if(solve())
        cout << "POSSIBLE" << endl;
    else
        cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

ll dp[55][55][3000];

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

    int n, K;
    cin >> n >> K;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j <= i; j++)
        {
            for (int k = 0; k <= K; k++)
            {
                if (k - 2 * j < 0)
                    continue;
                dp[i][j][k] = (2 * j + 1) * dp[i - 1][j][k - 2 * j] % MOD + (j + 1) * (j + 1) * dp[i - 1][j + 1][k - 2 * j] % MOD;
                if (j)
                    dp[i][j][k] += dp[i - 1][j - 1][k - 2 * j];
                dp[i][j][k] %= MOD;
            }
        }
    }
    cout << dp[n][0][K] << endl;
}


Measured memory_bytes: 65792
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main(){
    int a,b,cnt;
    cin >> a >> b;
    cnt=0;
    if(a<b){
        for (int i=a;i<b;i++){
            if(abs(a-i)==abs(b-i)){
                cout << i << endl;
                goto OUT;
            }
        }
    }else{
        for (int i=b;i<a;i++){
            if(abs(a-i)==abs(b-i)){
                cout << i << endl;
                goto OUT;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;
    OUT:
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>

using namespace std;

int main()
{
  int a, b, c;

  cin >> a >> b >> c;

  if (a < b && b < c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3080
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) a[i] = sc.nextLong();
        Arrays.sort(a);
        long INF = 1000_000_001L * 1000_000_001L;
        long l = -INF;
        long r = INF;
        while (r - l > 1) {
            long c = (l + r) / 2;
            long cnt = 0;
            for (int i = 0; i < n; i++) {
                int L = -1;
                int R = n;
                if (a[i] < 0) {
                    while (R - L > 1) {
                        int C = (L + R) / 2;
                        if (a[i] * a[C] < c) R = C;
                        else L = C;
                    }
                    cnt += n - R;
                } else {
                    while (R - L > 1) {
                        int C = (L + R) / 2;
                        if (a[i] * a[C] < c) L = C;
                        else R = C;
                    }
                    cnt += L + 1;
                }
                if (a[i] * a[i] < c) cnt--;
            }
            cnt /= 2;
            if (cnt < k) l = c;
            else r = c;
        }
        System.out.println(l);
    }
}

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

long long N, M, a[100009][3], maxn = -(1LL << 60);

int main() {
	cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		for(int j = 0; j < 3; j++) cin >> a[i][j];
	}
	for(int i = 0; i < 8; i++) {
		vector<long long>vec;
		for(int j = 1; j <= N; j++){
			long long S = 0;
			for(int k = 0; k < 3; k++){
				if((i / (1<<k)) % 2 == 0){
					S += a[j][k];
				} else {
					S -= a[j][k];
				}
			}
			vec.push_back(S);
		}
		sort(vec.begin(), vec.end());
		reverse(vec.begin(), vec.end());
		long long ans = 0;
		for(int j = 0; j < M; j++) ans += vec[j];
		maxn = max(maxn, ans);
	}
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
S = []
T = []

for i in range(n):
    s, t = map(str, input().split())
    t = int(t)
    S.append(s)
    T.append(t)

x = str(input())

for i in range(n):
    if S[i] == x:
        j = i

if j == n-1:
    print(0)
else:
    print(sum(T[j+1:]))


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll sum = accumulate(A.begin(), A.end(), 0LL);
    cout << (H <= sum ? "Yes" : "No") << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define ll long long
int main()
{
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    int ans[1000][1000] = {0};
    for(int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if(j >= a && i < b){
                ans[i][j] = 1;
            }
            if(j < a && i >= b){
                ans[i][j] = 1;
            }
            cout << ans[i][j];
            
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 5120