akhauriyash/Code-Regression huggingface dataset:
s = input()
x, y = [int(i) for i in input().split(" ")]

xl = []
yl = []

s = s + "T"

xf = True
l = 0
for i in range(0, len(s)):
    if s[i] == "T":
        if xf:
            xl.append(l)
            xf = False
            l = 0
        else:
            yl.append(l)
            xf = True
            l = 0
    else:
        l += 1

x -= xl[0]
xl = xl[1:]

def p(a, l):
    s = sum(a) + l
    if s < 0 or s % 2 == 1:
        return False
    else:
        dp = [[False for j in range(0, s // 2 + 1)] for i in range(0, len(a) + 1)]
        dp[0][0] = True
        for i in range(1, len(a) + 1):
            for j in range(0, s // 2 + 1):
                dp[i][j] = dp[i - 1][j] or (0 <= j - a[i - 1] and dp[i - 1][j - a[i - 1]])
        return dp[len(a)][s // 2]

if p(xl, x) and p(yl, y):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 107612
#include <bits/stdc++.h>
using namespace std;
int solve() {
  int n;
  cin>>n;
  int a[n];
  int b[n];
  int c[n];
  int dp[n][3];
  for(int i = 0; i<n; ++i) {
    cin>>a[i]>>b[i]>>c[i];
  }
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for(int i = 1; i<n; ++i) {
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i];
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i];
    dp[i][2] = max(dp[i-1][1], dp[i-1][0]) + c[i];
  }
  return max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
} 
int main() {
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 5980
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;

using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<ll, ll> pii;
typedef long double ld;

typedef pair<ld, ld> pld;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<ll> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> &a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> &a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> &a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;

void solve() {
    int s, w;
    cin >> s >> w;
    if (w >= s) put("unsafe");
    else put("safe");
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int t = 1;
//    cin >> t;
    while (t--) solve();
}


Measured memory_bytes: 3636
#pragma GCC optimize ("O3")
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;


int main(){
      int n,k;
      cin>>n>>k;
      string s;
      cin>>s;
      string stt=s;
      int kdkd=k;
      int pos=0;
      for(int r=0;r<n-1;r++){
            if(s[r]=='L'&&s[r+1]=='R'){
                  pos=r+1;
            }
            else if(pos!=0&&s[r]=='R'&&s[r+1]=='L'){
                  for(int j=pos;j<=r;j++){
                        s[j]='L';
                  }
                  --k;
            }
            if(k==0) break;
      }
      if(k>0){
            for(int j=pos;j<n;j++){
                  s[j]='L';
            }
            --k;
      }
      pos=0;
      if(k>0){
            for(int j=0;j<n;j++){
                  if(s[j]=='L'){
                        pos=j;
                        break;
                  }
            }
            for(int j=0;j<pos;j++){
                  s[j]='L';
            }
      }
      //cout<<pos<<" "<<s<<endl;
      ll ans=0;
      for(int j=0;j<n;j++){
            if(j==0&&s[j]=='L') continue;
            if(j==(n-1)&&s[j]=='R') continue;
            if(s[j]=='L'&&s[j-1]=='L') ans++;
            if(s[j]=='R'&&s[j+1]=='R') ans++;
      }
      //cout<<ans<<endl;

      for(int r=0;r<n-1;r++){
            if(stt[r]=='R'&&stt[r+1]=='L'){
                  pos=r+1;
            }
            else if(pos!=0&&stt[r]=='L'&&stt[r+1]=='R'){
                  for(int j=pos;j<=r;j++){
                        stt[j]='R';
                  }
                  --kdkd;
            }
            if(kdkd==0) break;
      }
      if(kdkd>0){
            for(int j=pos;j<n;j++){
                  stt[j]='R';
            }
            --k;
      }
      pos=0;
      if(kdkd>0){
            for(int j=0;j<n;j++){
                  if(stt[j]=='R'){
                        pos=j;
                        break;
                  }
            }
            for(int j=0;j<pos;j++){
                  stt[j]='R';
            }
      }
      ll ans2=0;
      for(int j=0;j<n;j++){
            if(j==0&&stt[j]=='L') continue;
            if(j==(n-1)&&stt[j]=='R') continue;
            if(stt[j]=='L'&&stt[j-1]=='L') ans2++;
            if(stt[j]=='R'&&stt[j+1]=='R') ans2++;
      }
      cout<<max(ans,ans2)<<endl;
      //cout<<s<<stt<<endl;

      return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
 
using namespace std;
 
int main(void){
  unsigned int N, X;
  cin >> N >> X;
  unsigned int L[N];
  for(int i=0; i<N; i++){
    cin >> L[i];
  }

  unsigned int Length = 0;
  unsigned int loop;
  for(loop=0; loop<N; loop++){
    Length += L[loop];
    
    if(Length > X){
      break;
    }
  }
  
  cout << loop+1 << endl;
  
  return 0;
}

Measured memory_bytes: 256
let n = read_int ()
let h n = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ps = h n
let qs, ns, fs, c, a, b = Array.(h n, make n 0, make n false, ref 0, ref 0, ref 0)
let g a r = if !r = 0 && a = ns then r := !c
let rec f i = if i >= n then (incr c; g ps a; g qs b; if !a * !b > 0 then (Printf.printf "%d\n" @@ abs (!a - !b); exit 0))
  else for j = 0 to n - 1 do if not fs.(j) then (fs.(j) <- true; ns.(i) <- j + 1; f (i + 1); fs.(j) <- false) done
let _ = f 0

Measured memory_bytes: 384
n=int(input())
s=[input() for i in range(n)]
nl={i:0 for i in set(s)}
c=0
for i in s:
  nl[i]+=1
  if nl[i]>c:
    c=nl[i]
ans=[i for i in set(s) if nl[i]==c]
ans.sort()
[print(i) for i in ans]

Measured memory_bytes: 49424
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
int vis[100005];
int f[1050],u[100],ans[100];

int main()
{
  //  ios::sync_with_stdio(false);
    /*cout << 4e5;
    ll n;
    cin >> n;
    if(n%2)
        cout << 0 << endl;
    else{

    }*/
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >> f[i];
    ll ans=10000000000000;
    for(int i=1;i<=100;i++){
        ll k=0;
        for(int j=0;j<n;j++)
            k+=(f[j]-i)*(f[j]-i);
        ans=min(k,ans);
    }
    cout << ans;


    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String x = sc.next();
		long count = 1;
		int a = x.indexOf("A");
		int b = x.lastIndexOf("Z");
		System.out.println(b-a+1);
	}
}

Measured memory_bytes: 14256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MAXN 100
#define MAXK 100000
int a[MAXN]; 
int n,k;
int dp[MAXN+1][MAXK+1];
int prefixsum[MAXK];

int main() {
    int i,j, totalways, fueraderango;
    scanf("%d %d",&n,&k);
    for (i=0; i<n; i++) {
        scanf("%d",&a[i]);
    }
    dp[0][0]=1;
    for (j=1; j<=k; j++) {
        dp[0][j]=0;
    }
    for(i=1;i<=n;i++) {
        prefixsum[0]=dp[i-1][0];
        for (j=1; j<=k; j++) {
            prefixsum[j]=(prefixsum[j-1]+dp[i-1][j])%MOD;
        }
        for(j=0;j<=k;j++) {
            totalways=prefixsum[j];
            fueraderango=j-a[i-1]-1;
            if (fueraderango >= 0) {
                totalways=(totalways-prefixsum[fueraderango]+MOD)%MOD;  
            }
            dp[i][j]=totalways;
        }
    }
  	printf("%d\n",dp[n][k]);
    return 0;
}


Measured memory_bytes: 43548
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
	long long int n,k;
	cin>>n>>k;
	long long int h[n],sum=0;
	for(int i=0;i<n;i++)
		cin>>h[i];
	if(k>=n)
	cout<<"0"<<endl;
	else
	{
		sort(h,h+n);
		for(int i=0;i<n-k;i++)
		sum=sum+h[i];
		cout<<sum;
	}
	
	return 0;
}

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

int main()
{
	int n;
	cin>>n;
	if(n==1)
	{
		cout<<"Hello World"<<endl;
	}
	else
	{
		int a,b;
		cin>>a>>b;
		cout<<a+b<<endl;
	}
	return 0;
}


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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/c.in", "r", stdin);
//  freopen("../IO/c.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int64_t n, k;
  in >> n >> k;
  n %= k;
  out << min(n, abs(n-k));
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define swap(a,b) {if(a<b) {int t=a;a=b;b=t;}}
int gcd(int a,int b){
	swap(a,b);
	int t;
	while(b!=0){
		t=a;
		a=b;
		b=t%b;
	}
	return a;
}
int main(){
	int m,i,j,k,t;
	long long int sum=0;
	cin>>k;
	for(i=1;i<=k;i++)
		for(j=1;j<=k;j++)
			for(m=1;m<=k;m++){
				t=gcd(i,j);
				sum+=gcd(t,m);
			}
	cout<<sum;
}

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

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int main()
{
  ll n,P;
  scanf("%lld %lld",&n,&P);
  ll ret=1;
  for(ll i=2;i*i<=P;i++)
  {
    if(P%i==0)
    {
      ll cnt=0;
      while(P%i==0)
      {
        P/=i;
        cnt++;
      }
      ll t=cnt/n;
      while(t--) ret=ret*(ll) i;
    }
  }
  if(n==1) ret=ret*P;
  printf("%lld\n",ret);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

ll GCD(ll a, ll b){
    if(a==0 && b==0) return INF;
    if(b==0) return a;
    else return GCD(b,a%b);
}

int main(){
    ll n,k; cin >> n >> k;
    vl a(n);
    ll mx = 0;
    rep(i,n){
        cin >> a[i];
        mx = max(a[i],mx);
    }
    if(k > mx){
        puts("IMPOSSIBLE");
        return 0;
    }
    ll mn = INF;
    rep(i,n-2){
        mn = min(mn, GCD(abs(a[i+1]-a[i]), abs(a[i+2]-a[i+1])));
    }
    //puts("###");
    bool flag = false;
    rep(i,n){
        if(abs(a[i]-k) % mn == 0) flag = true;
    }
    if(flag) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
}

Measured memory_bytes: 1024
#include<cstdio>
int N,P,A,C;
long T=1;
main()
{
  scanf("%d%d",&N,&P);
  for(int i=0;i<N;i++)scanf("%d",&A),C+=A%2,T*=2;
  printf("%ld",C?T/2:T*!P);
}

Measured memory_bytes: 128
import java.io.*;
class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        String[] strs = str.split(" ");
        int a = Integer.parseInt(strs[0]);
        int b = Integer.parseInt(strs[1]);
        int c = Integer.parseInt(strs[2]);
        int cnt = 0;
        for(int i = a; i <= b; i++){
            if((c % i) == 0){
                cnt++;
            }
        }
        System.out.println(cnt);
        br.close();
    }
}

Measured memory_bytes: 24380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <map>

using namespace std;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

int main(void) {
    int64_t N;
    string X;
    cin >> N >> X;
    int64_t cnt = count(X.begin(), X.end(), '1');

    int64_t m1 = 0, m2 = 0;
    for(int64_t i=0; i<N; i++) {
        if(X[i] == '1') {
            m2 += mod_pow(2L, N-1-i, cnt+1);
            m2 %= cnt+1;
            if(cnt <= 1) continue;
            m1 += mod_pow(2L, N-1-i, cnt-1);
            m1 %= cnt-1;
        }
    }

    vector<int64_t> f(300000);
    for(int64_t i=1; i<300000; i++) {
        f[i] = f[i % __builtin_popcountll(i)] + 1;
    }

    for(int64_t i=0; i<N; i++) {
        if(cnt == 1 && X[i] == '1') {
            cout << 0 << endl;
        } else if(X[i] == '1') {
            int64_t tmp = m1 - mod_pow(2L, N-1-i, cnt-1);
            tmp %= cnt-1;
            if(tmp < 0) tmp += cnt-1;
            cout << f[tmp]+1 << endl;
        } else {
            int64_t tmp = m2 + mod_pow(2L, N-1-i, cnt+1);
            tmp %= cnt+1;
            if(tmp < 0) tmp += cnt+1;
            cout << f[tmp]+1 << endl;
        }
    }
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int a = n;
	int d = 0;
	while (a > 0) {
		d += a % 10;
		a /= 10;
	}
	if (n%d == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t K, M;
  cin >> K;
  M = max(K + 1, (int64_t) 10);
  vector<int64_t> ans(M);

  vector<vector<string>> a, b;
  a = { {"0"}, {"1"}, {"2"}, {"3"}, {"4"}, {"5"}, {"6"}, {"7"}, {"8"}, {"9"} };
  for (int64_t i = 1; i < 10; i++) {
    ans.at(i) = i;
  }

  int64_t n = 9;
  string c;
  bool finished = false;
  while (n < K) {
    b = {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}};
    for (int64_t i = 0; i < 10; i++) {
      for (int64_t k = -1; k < 2; k++) {
        if ((i == 0 && k == -1) || (i == 9 && k == 1)) {
          continue;
        }
        for (int64_t j = 0; j < a.at(i + k).size(); j++) {
          c = to_string(i) + a.at(i + k).at(j);
          b.at(i).push_back(c);
          if (i != 0) {
            n++;
            ans.at(n) = stoll(c);
          }
          if (n >= K) {
            finished = true;
            break;
          }
        }
        if (finished) {
          break;
        }
      }
      if (finished) {
        break;
      }
    }
    if (finished) {
      break;
    }
    a = b;
  }
  cout << ans.at(K) << endl;
}

Measured memory_bytes: 6016
import java.util.*;class Main{public static void main(String[]z){int m=50001,i,j,n,v,x=5133,c=0;int[]b=new int[m+1],r=b.clone(),p=b.clone();for(i=1;i++<m;)if(b[i]<1)for(p[c++]=j=i;j<=m;j+=i)b[j]=1;for(i=0;i<x;++i)for(j=i;j<x;++j)if((v=p[i]+p[j])<m)++r[v];else break;for(Scanner s=new Scanner(System.in);(n=s.nextInt())>0;)System.out.println(r[n]);}}

Measured memory_bytes: 13000
#define N 100001
int p[N];int r[N];int f(int x){if(p[x]==x){return x;}return p[x]=f(p[x]);}int u(int x,int y){x=f(x);y=f(y);if(r[x]<r[y]){p[x]=y;r[y]+=r[x];}else {p[y]=x;r[x]+=r[y];}}int main(){long n,m,i,b[N],a[N][2];scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",&a[i][0],&a[i][1]);b[m]=(long long)n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>=0;i--){if(f(a[i][0])==f(a[i][1]))b[i]=b[i+1];else{b[i]=b[i+1]-(long)r[f(a[i][0])]*r[f(a[i][1])];u(a[i][0],a[i][1]);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);return 0;}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);
	ll w, h; cin >> h >> w;
	REP(i, h) REP(j, w) {
		string s; cin >> s;
		if (s == "snuke") {
			cout << char('A' + j) << i + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <ctime>
#include <map>
#include <assert.h>
#include <stack>
#include <set>
#include <bitset>
#include <queue>
#include <iomanip>
#include <cstring>
#include <algorithm>
using namespace std;

#define sacnf scanf
#define scnaf scanf
#define scnafi scanfi
#define pb push_back
#define Len size()
#define gchar getchar()
#define FOR(i,j,k) for(int (i)=(j);(i)<=(k);++(i))
#define mes(a,b) memset((a),(b),sizeof(a))
#define scanfi(a) scanf("%d",&(a))
#define scanfti(a,b) scanf("%d%d",&(a),&(b))
#define println(a) printf("%d\n",(a))
#define printIs(a) printf((a)?"Yes\n":"No\n")
#define print_b printf("\n")
#define IsNum(x) '0'<=(x)&&(x)<='9'
#define lt dir*2
#define rt dir*2+1

#define maxn 50010
#define maxm 26
#define inf 1061109567
//const long long inf=1e15;
#define INF 0x3f3f3f3f
#define eps 1e-9
#define E 2.718281828459
const double PI=acos(-1.0);
#define mod 1000
//const long long mod=1000000007;
#define MAXNUM 1000000000

typedef long long ll;
typedef unsigned long long ulld;
ll Abs(ll x) {return (x<0)?-x:x;}
int Read() {char ch;int res=0;while(ch=getchar(),!(IsNum(ch)));while(IsNum(ch)) res=res*10+ch-'0',ch=getchar();return res;}

int tmp[maxn];

int main()
{
    //freopen("data.in","r",stdin);
    //freopen("std.out","w",stdout);
    FOR(i,2,50000) tmp[i-1]=i&1?(i-1)/2*i:i/2*(i-1);
    int n;
    while(~scanfi(n))
    {
        int i;
        for(i=49999;i>0;i--)
        {
            if(n>=tmp[i]) break;
        }
        if(n==tmp[i])
        {
            FOR(j,1,i) printf(")");
            FOR(j,1,i) printf("(");
        }
        else
        {
            FOR(j,1,n-tmp[i]) printf(")");
            printf("()");FOR(j,1,i-n+tmp[i]) printf(")");
            FOR(j,1,i) printf("(");
        }
        print_b;
    }
    //clock_t ed=clock();
    //printf("\n\nTime Used : %.5lf Ms.\n",(double)(ed-st)/CLOCKS_PER_SEC);
    return 0;
}

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

# input
K, S = map(int, input().split())

# solve
ans = 0
for X in range(K + 1):
    for Y in range(K + 1):
        Z = S - X - Y
        if 0 <= Z and Z <= K:
            ans += 1

# output
print(ans)


Measured memory_bytes: 3060
#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<int, int>;

int main()
{
  string S, T;
  cin >> S >> T;
  
  bool flag = true;
  rep(i, S.size())
  {
    if (S[i] != T[i])
    {
      flag = false;
    }
  }
  
  flag ? printf("Yes") : printf("No");
}


Measured memory_bytes: 3688
n = int(input())
a = list(map(int, input().split()))
a.append(0)

kyokusyou = 0
count = 0
gezan = False
for i in range(n):
  if not gezan and a[i+1] < a[i]:
    count += a[i] - kyokusyou
    gezan = True
  elif gezan and a[i+1] > a[i]:
    gezan = False
    kyokusyou = a[i]

print(count)


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

using namespace std;

#define SPEED ios::sync_with_stdio(0),cin.tie(0);

const int N = 100005;
int n, a[N];

int main() 
{
    SPEED
    string s;
    cin >> s;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == '1') s[i] = '9';
        else if (s[i] == '9') s[i] = '1';
    }
    cout << s;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		// Formatter fm = new Formatter(System.out);
		List<String> ans = new ArrayList<String>();
		for (int[] in = readInts(); in != null; in = readInts()) {
			String format = b(in);
			System.out.println(format);
			// ans.add(s);
		}
		// fm.close();

	}

	private static String b(int[] in) {
		int a11 = in[0], a12 = in[1], b1 = in[2];
		int a21 = in[3], a22 = in[4], b2 = in[5];
		double D = a11 * a22 - a12 * a21;
		if (Double.compare(D, 0.0) == 0) {
			// continue;
		}
		int xx = +a22 * b1 - a12 * b2;
		int yy = +a11 * b2 - a21 * b1;
		double ansX = (xx / D);
		double ansY = (yy / D);
		if (ansX == 0) {
			ansX = 0.0 / 1.0;
		}
		if (ansY == 0) {
			ansY = +0.0 / 1.0;
		}
		// fm.format("%1$.3f", ansX);
		// fm.format(" %1$.3f\n", ansY);
		// fm.flush();
		String format = String.format("%.3f %.3f", ansX, ansY);
		return format;
	}

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

	private static int[] readInts() throws IOException {
		String readLine = br.readLine();
		if (readLine == null || readLine.equals("")) {
			return null;
		}
		String[] s = readLine.split(" ");
		int[] result = new int[s.length];
		for (int i = 0; i < result.length; i++)
			result[i] = Integer.parseInt(s[i], 10);

		return result;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.awt.image.BandedSampleModel;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {


    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int arr[]=new int[n];
        for(int i=0;i<n;i++)
        {
            arr[i]=sc.nextInt();
        }
        int ans=0;
        for(int i=0;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(arr[i]+arr[j]>arr[k]&&arr[i]+arr[k]>arr[j]&&arr[k]+arr[j]>arr[i]&&arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[i]!=arr[k])
                    {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 36896
h,w = map(int,input().split())
a = [input() for _ in range(h)]
b = []
for i in range(h):
    if a[i] != '.'*w:
        b.append(a[i])
ans = []
for i in range(w):
    flag = False
    for j in range(len(b)):
        flag |= b[j][i]=='#'
    if not flag:
        ans.append(i)
for i in b:
    for j,k in enumerate(i):
        if j not in ans:
            print(k,end='')
    print('')


Measured memory_bytes: 4468
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int[] c = new int[a];
        int[] d = new int[a];
        int number = 0;
        int answer = 10000;
        for (int i = 0; i < a; i++) {
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
            if (b >= d[i]) {
                if (c[i] < answer) {
                    answer = c[i];
                }
            }
        }
        if (answer == 10000) {
            System.out.println("TLE");
        } else {
            System.out.println(answer);
        }
    }

}

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

int main(){


    int n; cin >> n;
    double t, a; cin >> t >> a;
    vector<double> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    double ans_id, ans_min = 1e9;
    for(int i = 0; i < n; i++){
        if(ans_min > abs(a - (t - h[i] * 0.006))){
            ans_min = abs(a - (t - h[i] * 0.006));
            ans_id = i + 1;
        }
    }

    cout << ans_id << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	if (A == 7){
		if (B == C && B == 5){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	else if (B == 7){
		if (A == C && C == 5){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	else if (C == 7){
		if (B == A && A == 5){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
/*
   Creator - Glitched
   Yeet!!
*/
#include "bits/stdc++.h"
using namespace std;

#define testcases ll T;cin>>T;while(T--)
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define loopr(i,x,n) for(ll i=n-1;i>=x;i--)
#define ff first
#define ss second
#define pb push_back
#define elif else if
#define flush cout<<"\n"
#define mod 1E9+7
#define L LONG_MAX
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
const string yes = "Yes", no = "No";

int main()
{	
	fastio;
	ll x;
	cin>>x;

	ll ans;

	ans = (x/500)*1000;
	x = x%500;
	ans+= (x/5)*5;
	cout<<ans;

}

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

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll a,b,n;cin>>a>>b>>n;
    ll x;
    if(n/b==0)x=n;
    else x=b-1;
    cout<<a*x/b-a*(x/b);
    
}

Measured memory_bytes: 3604
list = [int(input()) for i in range (4)]#A,B,C,X
num=0
for i in range (list[0]+1):
    for j in range (list[1]+1):
        for k in range (list[2]+1):
            if 500*i+100*j+50*k == list[3]:
                num += 1
                
print (num)

Measured memory_bytes: 3060
input_text = input()
output_text = ''

if input_text == 'A':
  output_text = 'T'
elif input_text == 'C':
  output_text = 'G'
elif input_text == 'G':
  output_text = 'C'
else:
  output_text = 'A'
  
print(output_text)

Measured memory_bytes: 2940
<?php

fscanf(STDIN, "%d", $k);

$arr = [];
for ($i = 1; $i < 10; ++$i) {
    $arr[] = $i;
}

while(1) {
    if (count($arr) > $k) {
        break;
    }

    $tmp = [];
    $keta = strlen(max($arr));
    foreach ($arr as $x) {
        if (strlen($x) !== $keta) {
            continue;
        }

        $y = $x % 10;
        for ($i = -1; $i <= 1; ++$i) {
            $z = $y + $i;
            if ($z < 0 || $z > 9) {
                continue;
            }

            $nx = $x * 10 + $z;
            $tmp[] = $nx;
        }
    }
    $arr = array_merge($arr, $tmp);
}

echo $arr[$k - 1];


Measured memory_bytes: 25072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int x;
  vector<int> vx;
  vector<int> vx_;
  cin >> n;
  REP(i,n){
    cin >> x;
    vx.push_back(x);
    vx_.push_back(x);
  }
  SORT(vx);
  int left = vx[n/2-1];
  int right = vx[n/2];
  REP(i,n){
    if (vx_[i] <= left){
      cout << right << endl;
    }else{
      cout << left << endl;
    }
  }
}


Measured memory_bytes: 3948
// https://atcoder.jp/contests/aising2020/tasks/aising2020_b
#include<bits/stdc++.h>
using namespace std;

int main(int argc, char* argv[]) {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	bool found = false;
	do {
		if (b > a && c > b) {
			found = true;
			break;
		} else if (b <= a) b*=2;
	    else if (c <= b) c*=2;
	    else a*=2;
	} while (k--);
	if (found) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3624
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef pair<ll, ll> P;
typedef vector<ll> vll;

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n;
        vll a(5);
        cin >> n;
        rep(i, 5) cin >> a[i];
        ll ans = 0;
        ll minel = ll_inf, minid = 1;
        rep(i, 5) {
            if (a[i] < minel) minel = a[i], minid = i;
        }
        ans += minid;
        ans += ceil(double(n) / minel);
        ans += 5 - (minid + 1);
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int cnt = 0, ans = 0;

  for (int i = 0; i < S.size(); i++) { 
    if (S[i] == 'R') {
      cnt += 1;
      ans = max(ans, cnt);
    }
    else cnt = 0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3572
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in); 
      
        int n = sc.nextInt();
        int ans = 0;

        for(int i = 1;i*i <= n;i++){
           ans = i*i;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int dp[100005];
vector<int>v[100005];


int dfs(int n,int s){
    if (v[s].size()==0) {
        dp[s]=0;
        return 0;
    }
    if (dp[s]!=-1) {
        return dp[s];
    }
    for (int i = 0; i <v[s].size(); ++i) {
        int temp=dfs(n,v[s][i])+1;
        dp[s]=max(dp[s],temp);
    }
    return dp[s];

}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    memset(dp,-1,sizeof(dp));
    cin>>n>>m;
    for (int i = 0; i <m ; ++i) {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
    }
    for (int j = 1; j <=n ; ++j) {
        dfs(n,j);
    }
    cout<<*max_element(dp+1,dp+n+1);


    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    while(true){
        int x, y;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        if(x > y) swap(x, y);
        printf("%d %d\n", x, y);
    }
}


Measured memory_bytes: 3136
// C++ 14
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <math.h>

#define ll long long
#define Int ll
#define loop(__x, __start, __end) for(Int __x = __start; __x < __end; __x++)
#define loopdown(__x, __start, __end) for(Int __x = __start; __x > __end; __x--)
#define rep(__n) for(Int __x = 0; __x < __n; __x++)
#define span(__a,__x,__y) __a.begin()+__x,__a.begin()+__y
#define span_all(__a) __a.begin(),__a.end()
#define len(__x) (__x.size())
#define last(__x) (__x[__x.size()-1])

using namespace std;

struct Point {
  Int x, y;
  Point(Int x, Int y): x(x), y(y) {}
  Point(): x(0), y(0) {}

  bool operator< (const Point &p1) const {
    return x < p1.x && y < p1.y;
  }
};
ostream & operator << (ostream & out, Point const & v) {
  out << "Point(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Point & v) {
  Int x, y;
  in >> x; in >> y; v.x = x; v.y = y;
  return in;
}

// Geometry

#define EPS 0.0000000001

class Vector2 {
public:
  double x, y;
  
  Vector2(double x = 0, double y = 0): x(x), y(y) {}
  
  Vector2 operator + (Vector2 v) { return Vector2(x + v.x, y + v.y); }
  Vector2 operator - (Vector2 v) { return Vector2(x - v.x, y - v.y); }
  Vector2 operator * (double k) { return Vector2(x * k, y * k); }
  Vector2 operator / (double k) { return Vector2(x / k, y / k); }
  
  double length() { return sqrt(norm()); }
  double norm() { return x * x + y * y; }
  double dot (Vector2 v) { return x * v.x + y * v.y; }
  double cross (Vector2 v) { return x * v.y - y * v.x; }
  
  bool operator < (const Vector2 &v) const {
    return x != v.x ? x < v.x : y < v.y;
  }
  
  bool operator == (const Vector2 &v) const {
    return fabs(x - v.x) < EPS && fabs(y - v.y) < EPS;
  }
};

ostream & operator << (ostream & out, Vector2 const & v) { 
  out<< "Vector2(" << v.x << ", " << v.y << ')';
  return out;
}

istream & operator >> (istream & in, Vector2 & v) { 
  double x, y;
  in >> x;
  in >> y;
  v.x = x;
  v.y = y;
  return in;
}

Int N;
vector<vector<Int> > G(101);
vector<Int> D(101, -1);

void input() {
  cin >> N;
  Int u, c, v;
  rep(N) {
    cin >> u >> c;u--;
    rep(c) {
      cin >> v;v--;
      G.at(u).push_back(v);
    }
  }
}

void bfs() {
  queue<Int> Q;
  Q.push(0);
  D.at(0) = 0;
  while (Q.size()) {
    Int u = Q.front();Q.pop();
    for (auto v: G.at(u)) {
      if (D.at(v) != -1) continue;
      Q.push(v);
      D.at(v) = D.at(u) + 1;
    }
  }
}

void solve() {
  bfs();
  for (int i=0; i<N; i++) {
    cout << i+1 << " " << D.at(i) << endl;
  }
}

int main() {
  input();
  solve();
  return 0;
}



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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

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; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	if (s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  UnionFind uf(n);
  while (m--) {
    int x, y, z; cin >> x >> y >> z, --x, --y;
    uf.unite(x, y);
  }
  set<int> se;
  for (int i = 0; i < n; ++i) se.insert(uf.find(i));
  cout << se.size() << '\n';
}

Measured memory_bytes: 5376
#include <stdio.h>

int main() {
	int H;
	int N;
	
	scanf("%d", &H);
	scanf("%d", &N);
	
	
	for(int i = 0; i<N; i++){
		int A;
		scanf("%d", &A);
		H -=A;
		
	}
	if(H<=0)
	puts("Yes");
	else
	puts("No");
	
  return 0;
}

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


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
const int INF = 1e9;
const int MOD = 1e9+7;


#define lint long long
const lint LINF = 1e18;

using namespace std;
string s;
lint ans;

int main(){
  cin >> s;
  lint k = s.size();
  lint a = stoll(s);

  REP(i,pow(2,k-1)){
    lint num = i;
    string s2 = "";
    s2 += s[0];
    int now;
    REP(j,k-1){
      now = num%2;
      num /= 2;
      if(now==1){
        ans += stoll(s2);
        s2 = "";
        s2 += s[j+1];
      }
      else s2 += s[j+1];
    }
    ans += stoll(s2);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

    ll N,K;
    cin >> N >> K;

    ll idx=0, ans=0;

    vector<P> ab(N);

    rep(i, N) {
        ll a,b;
        cin >> a >> b;
        ab[i] = P(a, b);
    }

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

    rep(i, N) {
        if (idx<K and K<=idx+ab[i].second) {
            ans=ab[i].first;
        }
        idx+=ab[i].second;
    }

    cout << ans << endl;

}


Measured memory_bytes: 1792
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

typedef long long ll;

int validate(int n, int b, int k){
  int count = 0;
  for(int a = 1; a <= n; a++){
    if(a % b >= k){
      ++count;
    }
  }
  return count;
}

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

  int n, k;
  cin >> n >> k;

  ll sum = 0;
  for(int b = max(k, 1); b <= n; b++){
    ll d = (b - k) * (n / b);
    if(n % b >= k) d += (n - (b * (n / b)) - k + 1);
    sum += d;
  }

  if(k == 0) sum -= n;

  cout << sum << endl;

  return 0;
}


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



int main(){
  int n;
  int i;
  bool ok = true;
  
  cin >> n;
  
  vector<int> a(n);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }

  for(i = 0; i < n; i++){
    if(a.at(i) %2 == 0){
      if((a.at(i) %3 != 0) && (a.at(i) %5 != 0)){
        ok = false;
        break;
      }
    }
  }
  
  if(ok == true)
    cout << "APPROVED" << endl;
  else
    cout << "DENIED" << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin >> N >> M;
  long long int A[N];
  vector<long long int> ans;
  for(int i=0;i<N;i++){
    cin >> A[i];
    ans.push_back(A[i]);
  }
  sort(ans.begin(),ans.end(),greater<long long int>());
  for(int i=0;i<M;i++){
    *ans.begin()/=2;
    if (i==M-1){
      break;
    }
    for(vector<long long int>::iterator e=(ans.begin()+1);e!=ans.end();e++){
      if(*e>*ans.begin()){
        *e/=2;
        i++;
        if (i==M-1){
          break;
        }
      }else {
        break;
      }
    }
    sort(ans.begin(),ans.end(),greater<long long int>());
  }
  long long int sum=0;
  for(vector<long long int>::iterator e=ans.begin();e!=ans.end();e++){
    sum+=*e;
  }
  cout << sum;
}


Measured memory_bytes: 1912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,ll>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N,K;
    cin>>N>>K;
    vector<ll> A(N);
    rep(i,N)cin>>A.at(i);
    rep(i,N-K){
        if(A.at(K+i)>A.at(i))cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 4840
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())

    ans = ''
    while N > 0:
        d, m = divmod(N, 26)
        if not m:
            d -= 1
            m = 26
        ans += chr(96 + m)
        N = d
    print(ans[::-1])


main()


Measured memory_bytes: 9112
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
ans = 0
for _ in range(n):
  X = []
  a = list(map(int,input().split()))
  for i in range(m):
    X.append(a[i]*b[i])
  if sum(X)+c > 0:  
    ans += 1
print(ans)

Measured memory_bytes: 3060
import sys
import numpy as np

n, *aaa = map(int, sys.stdin.buffer.read().split())
aaa = [a for a in aaa if a != 0]
n = len(aaa)

fft_len = 1 << 19

P = 200003
PR = 2
convert = [0] * P
rev_con = [0] * P
rev_con[0] = 1
tmp = 1
for i in range(1, P):
    tmp = tmp * PR % P
    convert[tmp] = i
    rev_con[i] = tmp

ans = 0
f = np.zeros(P)
for a in aaa:
    f[convert[a]] += 1
    ans -= a * a % P

Ff = np.fft.rfft(f, fft_len)
Fff = Ff * Ff
g = np.rint(np.fft.irfft(Fff, fft_len))
for i, c in enumerate(g):
    if c != 0:
        ans += rev_con[i % (P - 1)] * int(c + 1e-6)

print(ans // 2)


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


int main() {

  int N;
  string S;
  cin >> N >> S;

  long long countR = 0;
  long long countG = 0;
  long long countB = 0;

  for (int i = 0; i < N; i++) {
    if (S[i] == 'R') {
      countR++;
    } else if(S[i] == 'G') {
      countG++;
    } else {
      countB++;
    }
  }

  long long answer = countR * countG * countB;
  
  bool flg = true;
  int range = 0;
  while (flg) {
    if (N <= range * 2) {
      flg = false;
    } else {
      for (int i = 0; i < N - (range * 2); i++) {
        char s1 = S[i];
        char s2 = S[i + range];
        char s3 = S[i + range * 2];
        if(s1 != s2 && s2 != s3 && s3 != s1) {
          answer--;
        }
      }
      range++;
    }
  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 3632
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    went = [0] * N
    went[0] = 1
    Flag = True
    check = [0]
    cnt = 1
    now = 0
    while Flag and (cnt <= K + 1):
        now = A[now] - 1
        if went[now] == 1:
            ind = check.index(now)
            if ind == 0:
                cnt = len(check)
            else:
                cnt = len(check) - ind

            Flag = False
        else:
            check.append(now)
            went[now] = 1
            cnt += 1
            continue

    if len(check) > K:
        print(check[K] + 1)
    else:
        if ind == 0:
            K = K % cnt
            print(check[K] + 1)
        else:
            ind -= 1
            K = (K - ind - 1) % cnt
            print(check[ind + K + 1] + 1)


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin>>n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0; i<n; i++) cin>>s[i]>>t[i];
  string x;
  cin>>x;
  int k=1;
  for(int i=0; i<n; i++) {
    if(s[i] == x) {
      k += i;
      break;
    }
  }
  int sum=0;
  for(int i=k; i<n; i++){
  	sum += t[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    string s;
    cin >> s;

    for (int i = 0; i < s.length(); i++) {
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;

const int N = 1e5 + 5 ;
int n , arr[N],DP[N];

int calc(int idx){
    if (idx == n-1)return 0;
    if (idx >= n) return 1e9;
    if (DP[idx] != -1) return DP[idx];
    int one = calc(idx + 1) + abs(arr[idx+1] - arr[idx]);
    int two = calc(idx + 2) + abs(arr[idx+2] - arr[idx]);
    return DP[idx] = min(one,two);
}

int main(){
    fastIO;
    cin>>n;
    memset(DP,-1,sizeof DP);
    for(int i = 0 ; i<n ; i++){
        cin>>arr[i];
    }
    cout<<calc(0);
}


Measured memory_bytes: 10624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>

using namespace std;

int a, b, c;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> a;
    for (int i = 1; i <= a; i++)
    {
    	if (1 <= i && i < 10) b++;
    	if (100 <= i && i < 1000) b++;
    	if (10000 <= i && i < 100000) b++;
    }
    cout << b;
}


Measured memory_bytes: 256