akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    cout<<"NG"<<endl;
}



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

using namespace std;

int main()
{
    int n;
    cin >> n;
    bool ok=1;
    while(n--)
    {
        int a;
        cin >> a;
        if((a%2)==0)
        {
            if((a%3)!=0&&(a%5)!=0) ok=0;
        }
    }
    if(ok) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
//    String s=sc.next();
    int a=sc.nextInt();
    int b=sc.nextInt();
    int x=sc.nextInt();
    System.out.println((a<=x&&x<=a+b)?"YES":"NO");
  }
}

Measured memory_bytes: 21332
N,M =  map( int ,input().split())
H = list(map( int , input().split()))
A_B = [[0] * 2  for i in range(M)]
J = [0]*N
for i in range(M):
    A,B = map( int ,input().split())
    A_B[i][0] = A
    A_B[i][1] = B
for j in range(M):
    if H[A_B[j][0]-1] > H[A_B[j][1]-1]:
        if J[A_B[j][0]-1] != -1:
            J[A_B[j][0]-1] = 1
        J[A_B[j][1]-1] =-1
    elif H[A_B[j][0]-1] < H[A_B[j][1]-1]:
        J[A_B[j][0]-1] =-1
        if J[A_B[j][1]-1] != -1:
            J[A_B[j][1]-1] = 1
    else:
        J[A_B[j][0]-1] =-1
        J[A_B[j][1]-1] =-1
for l in range(N):
    if J[l] == 0:
        J[l] = 1
print(J.count(1))

Measured memory_bytes: 28940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 200003
#define MOD 1000000007
using Graph=vector<vector<pair<int,double>>>;

double distance(ll x1,ll y1,ll x2,ll y2){
  return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

int main(){
  ll xs,ys,xt,yt;
  cin>>xs>>ys>>xt>>yt;
  int N;
  cin>>N;
  vector<ll> x(N),y(N),r(N);
  for(int i=0;i<N;i++){
    cin>>x.at(i)>>y.at(i)>>r.at(i);
  }

  Graph G(N+2);
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      double d=distance(x.at(i),y.at(i),x.at(j),y.at(j))-(double)(r.at(i)+r.at(j));
      d=max(d,0.0);
      G.at(i+1).push_back(make_pair(j+1,d));
      G.at(j+1).push_back(make_pair(i+1,d));
    }
  }

  for(int i=0;i<N;i++){
    double d;
    d=distance(x.at(i),y.at(i),xs,ys)-(double)r.at(i);
    d=max(d,0.0);
    G.at(0).push_back(make_pair(i+1,d));
    d=distance(x.at(i),y.at(i),xt,yt)-(double)r.at(i);
    d=max(d,0.0);
    G.at(i+1).push_back(make_pair(N+1,d));
  }
  G.at(0).push_back(make_pair(N+1,distance(xs,ys,xt,yt)));

  vector<double> dist(N+2,1.0e20);
  dist.at(0)=0.0;
  priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> pq;
  pq.push(make_pair(dist.at(0),0));
  while(!pq.empty()){
    int v=pq.top().second;
    pq.pop();
    for(auto p:G.at(v)){
      int nv=p.first;
      double d=p.second;
      if(dist.at(v)+d<dist.at(nv)){
        dist.at(nv)=dist.at(v)+d;
        pq.push(make_pair(dist.at(nv),nv));
      }
    }
  }

  printf("%.10lf\n",dist.at(N+1));
}


Measured memory_bytes: 21636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func abs(n int) int {
	if n >= 0 {
		return n
	}
	return -n
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n, k := scanInt(), scanInt()
	var ans int

	r := n % k
	if r == 0 {
		ans = 0
	} else {
		if abs(r-k) < n {
			ans = abs(r - k)
		} else {
			ans = n
		}

	}

	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
main(){
  int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(int i=0;i<h;++i)cin>>s[i];
  
  for(int i=0;i<h;++i){
    bool lf=false;
    for(int j=0;j<w;++j){
      string t(w,'.');
      if(t==s[i])continue;
      bool ok=false;
      for(int k=0;k<h;++k)if(s[k][j]=='#')ok=true;
      if(ok){
        cout<<s[i][j];
        lf=true;
      }
    }
    if(lf)cout<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define INF 1e9L
#define EPS 1e-9
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
    ll x,y;
    cin >> x >> y;
    int ans = 0;
    while(1){
        if(x <= y)ans++;
        else break;
        x *= 2;
    }
    pr(ans);
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  string s;
  cin>>s;
  bool ok = false;
  int n = s.size();
  rep(i,n){
    if(s[i]=='7')ok=true;
  }
  cout<<(ok?"Yes":"No")<<endl;

}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

bool canMonth(char fst, char snd) {
  return ((fst - '0') == 0 && (snd - '0') != 0) || ((fst - '0') == 1 && (snd - '0') < 3);
}

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

  if (a >= 13) {
    cout << b << endl;
  } else if ((a >= 6) && (a <= 12)) {
    cout << b / 2 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
	return b==0?a:gcd(b,a%b);
}
int main()
{
	int a,b,d;
	while(cin>>a>>b)
	{
	if(a<b)
	{
		int m=a;
		a=b;
		b=m;
	}
	d=gcd(a,b);
	cout<<d<<" "<<a/d*b<<endl;
   }
	return 0;	
}

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

using namespace std;

int main(int argc, char const *argv[]) {
	int count,temp,tens,sum;
	vector<int> v;
	tens = sum = 0;
	cin >> count;
	for (size_t i = 0; i < count; i++) {
		cin >> temp;
		if (temp % 10 == 0) {
			tens += temp;
		}
		else{
			v.push_back(temp);
		}
	}
	sort(v.begin(),v.end());
	for (size_t i = 0; i < v.size(); i++) {
		sum += v[i];
	}
	if (sum % 10 == 0) {
		if (v.size() > 1) {
			sum -= v[0];
			std::cout << sum+tens << '\n';
		}
		else {
			std::cout << 0 << '\n';
		}
	}
	else{
		std::cout << sum+tens << '\n';
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,now,maxn;
char s[101];
int main()
{
	cin>>n>>s;
	for(int i=0;i<=n-1;i++)
	{
		if(s[i]=='I')
		{
			now++;
		}
		else
		{
			now--;
		}
		maxn=max(maxn,now);
	}
	cout<<maxn;
}

Measured memory_bytes: 256
def main():
    n, t = map(int, input().split())
    ans = 100000000
    for i in range(n):
        c, tt = map(int, input().split())
        if tt <= t:
            ans = min(ans, c)
    if ans >= 1000000:
        print('TLE')
    else:
        print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
from collections import Counter

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
comb = Combination(N + 100)

cntA = Counter(A)
X = [a for a, c in cntA.items() if c == 2][0]
l, r = [i for i, a in enumerate(A) if a == X]

ans = [N]
for leng in range(2, N + 2):
    M = comb.ncr(N + 1, leng)

    L = l + (N - r)
    D = comb.ncr(L, leng - 1)
    ans.append((M - D) % MOD)

print(*ans, sep='\n')


Measured memory_bytes: 32424
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 998244353;
const ll maxn = 100005;
const ll mm = 1e+18;
void solve()
{
    int n,k;
    cin>>n>>k;
    vector<pair<int,int>>v(k);
    for(int i=0;i<k;i++){
        cin>>v[i].f>>v[i].s;
    }
    int dp[n+1]={0};
    int pre[n+1]={0};
    dp[1]=1;
    pre[1]=1;
    for(int i=2;i<=n;i++){
        for(int j=0;j<k;j++){
            int l=max(1LL,i-v[j].s);
            int r=max(0LL,i-v[j].f);
            //deb(l,r);
            dp[i]=(dp[i]+(pre[r]-pre[l-1]+mod)%mod)%mod;
        }
        //deb(i,dp[i]);
        pre[i]=(pre[i-1]+dp[i])%mod;
    }
    cout<<dp[n];
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 6776
#include <iostream>
#include <vector>
#include <utility>
#include <string>

using namespace std;

using card = pair<char, int>;

vector<card> bubble_sort(vector<card> v, int n)
{
  for (int i = 0; i < n; i++)
  {
    for (int j = n - 1; j > i; j--)
      if (v[j].second < v[j - 1].second)
        swap(v[j], v[j - 1]);
  }
  return v;
}

vector<card> selection_sort(vector<card> v, int n)
{
  for (int i = 0; i < n; i++)
  {
    int minIndex = i;
    for (int j = i; j < n; ++j)
      if (v[j].second < v[minIndex].second)
        minIndex = j;
    swap(v[i], v[minIndex]);
  }
  return v;
}

bool is_stable(vector<card> v, vector<card> original)
{
  for (int i = 0; i < v.size(); i++)
    for (int j = i + 1; j < v.size(); j++)
      for (int a = 0; a < v.size(); a++)
        for (int b = a + 1; b < v.size(); b++)
          if (original[i].second == original[j].second && original[i] == v[b] && original[j] == v[a])
            // if (v[i].second == v[j].second && v[i] == original[b] && v[j] == original[a])
            return false;
  return true;
}

void printCards(vector<card> v, string delim)
{
  for (int i = 0; i < v.size() - 1; i++)
    cout << v[i].first << v[i].second << delim;
  cout << v[v.size() - 1].first << v[v.size() - 1].second << endl;
}

int main()
{
  int n;
  string tmp;
  vector<card> bubble, selection;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> tmp;
    bubble.push_back(card(tmp[0], (int)tmp[1] - 48));
    selection.push_back(card(tmp[0], (int)tmp[1] - 48));
  }

  bubble = bubble_sort(bubble, n);
  selection = selection_sort(selection, n);

  printCards(bubble, " ");
  printf("Stable\n");
  printCards(selection, " ");
  if (is_stable(selection, bubble))
    printf("Stable\n");
  else
    printf("Not stable\n");
  return 0;
}

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

long long cal_gcd(long long a, long long b){
  if (a%b==0){
    return(b);
  }
  else{
    return(cal_gcd(b,a%b));
  }
}

map<long long, long long> prime_list(long long n){
  map<long long, long long> ans;
  for(long long i=2;i*i<=n;++i){
    while(n%i==0){
      ++ans[i];
      n=n/i;
    }
  }
  if(n!=1){
    ++ans[n];
  }
  return ans;
}

int main(){
	long long A, B;
	cin >> A >> B;
	long long gcd = cal_gcd(A, B);
	cout << prime_list(gcd).size() + 1 << endl;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<functional>
#include<vector>

#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n;
int a[200010];
int b[200010];

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n;
    Forn(i, n) cin >> a[i];
    int ans = 0;
    for(int i=n; i>=1; i--)
    {
        int tot = 0;
        for(int j=i*2; j<=n; j+=i) tot += b[j];
        if(tot%2!=a[i])
        {
            b[i] = 1;
            ans++;
        }
    }
    cout << ans << endl;
    Forn(i, n) if(b[i]) cout << i << " ";
    cout << endl;

}


Measured memory_bytes: 2432
#include <cstdio>

int main()
{
	char s[4];
	scanf("%s\n", s);
	if (s[2] == '\0')
	{
		printf("%s", s);
	}
	else
	{
		for (int i = 2; i >= 0; --i)
		{
			printf("%c", s[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 128
import collections
a, b = map(int, input().split())
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

n = gcd(a, b)
c = collections.Counter(prime_factorize(n))
print(len(c.keys())+1)

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

long dp[400][200][200];

int main(){
    int H, W;
    long a[200][200];
    cin >> H >> W;
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cin >> a[i][j];
        }
    }
    dp[0][0][0] = a[0][0];
    for(int i = 1; i <= H+W-2; i++){
        for(int j = 0; j < W; j++){
            if(i-j < 0 || i-j >= H) continue;
            for(int k = 0; k < W; k++){
                if(i-k < 0 || i-k >= H) continue;
                if(j > 0 && k > 0) dp[i][j][k] = dp[i-1][j-1][k-1];
                if(i-j-1 >= 0 && k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k-1]);
                if(i-k-1 >= 0 && j > 0) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j-1][k]);
                if(i-j-1 >= 0 && i-k-1 >= 0) dp[i][j][k] = max(dp[i][j][k], dp[i-1][j][k]);
                               
                if(j == k) dp[i][j][k] += a[i-j][j];
                else dp[i][j][k] += (a[i-j][j]+a[i-k][k]);
                //cout << i <<  ' ' << j <<  ' ' << k << ' ' << dp[i][j][k] << endl;
            }
        }
    }
    cout << dp[H+W-2][W-1][W-1] << endl;
}

Measured memory_bytes: 123520
#include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define REP(i,x) for(int i=0;i<(int)(x);i++)
    #define REPS(i,x) for(int i=1;i<=(int)(x);i++)
    #define mp(a,b) make_pair(a, b)
    #define pb push_back
    #define eb emplace_back
    #define ll long long
    #define MAX 10000000
    int main()
    { int a,b,n;
    cin>>a>>b>>n;
    int p=(a/b); 
  if(a%b==0) { p*=n;
    cout<<p<<endl;
    }
    else {
        p+=1;p*=n;
        cout<<p<<endl;
    }
    }

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define ulli unsigned lli
#define ld long double
#define pb push_back
#define mp make_pair
#define bp pop_back
#define vi vector<int>
#define vvi vector< vector<int> >
#define vli vector<lli>
#define vvli vector< vector<lli> >
#define pii pair <int, int>
#define pli pair <lli, lli>
#define vpi vector<pii>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define forn(i,n) for(i=0;i<n;i++)
#define rof(i,k,n) for(i=k;i>=n;i--)
#define wh(k) while(k--)
#define mod 1000000007
#define all(i,m) auto i=m.begin();i!=m.end();i++
#define mii map<int,int>
#define F first
#define S second

const int MAX=1000000;

int main()
{
    fast;
    int x;
    cin>>x;
    cout<<(!x)<<'\n';
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>


using namespace std;



int main() {

	int A, B;
	string S;
	bool ans = true;

	cin >> A >> B;
	cin >> S;
	
	for (int i = 0; i < A + B + 1; i++) {
		if (S[i] != '-' && i == A) ans = false;
		if (S[i] == '-' && i != A) ans = false;
	}
	if (ans) cout << "Yes";
	else cout << "No";

	return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
  int a, b, ans, i;
  scanf("%d%d", &a, &b);
  if(a==1 && b==2) {printf("3\n");}
  else if(a==1 && b==3){printf("2\n");}
  else if(a==2 && b==1){printf("3\n");}
  else if(a==2 && b==3){printf("1\n");}
  else if(a==3 && b==1){printf("2\n");}
  else if(a==3 && b==2){printf("1\n");}
}

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

int main() {
	int n; cin >> n;
	vector<int> p(n + 1);
	rep(i, n) cin >> p[i + 1];

	int ans = 0;
	int minV = 200000 + 1;
	for (int i = 1; i <= n; i++) {
		if (p[i] <= minV) {
			ans++;
			minV = p[i];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int main(){
  int n;
  cin>>n;
  vector<int>a(n+1),b(n);
  rep(i,n+1)cin>>a[i];
  rep(i,n)cin>>b[i];

  ll ans=0;
  rep(i,n){
    if(a[i]>=b[i]){
      ans+=b[i];
    }
    else{
      b[i]-=a[i];
      ans+=a[i];
      ans+=min(a[i+1],b[i]);
      a[i+1]=max(a[i+1]-b[i],0);
    }
  }

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


Measured memory_bytes: 1024
#include <stdio.h>

int min(int a, int b, int c){
    int r = a;
    if (a > b) r = b;
    if (r > c) r = c;
    return r;
}
int main(){
    int n;
    int a;
    int b;
    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    scanf("%d", &n);
    scanf("%d %d", &a, &b);
    int p[n];
    for(int i = 0; i < n; i++){
        scanf("%d", &p[i]);
        if(p[i] <= a) count1++;
        if(p[i] > b) count3++;
    }
    count2 = n - count1 - count3;
    //printf("%d %d %d", count1, count2, count3);
    int r = min(count1, count2, count3);
    printf("%d\n", r);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;

int GetDigit(int num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

int main(){
   int N; cin>>N;
   int now = 1;
   int ans = 0;

   for(int i=1;i<=N;i++){

       if( GetDigit(i) % 2 == 1) ans++;

   }

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

Measured memory_bytes: 256
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n+1)

    def sum(self, i):  # sum in [0, i]
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):  # i > 0
        assert i > 0
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


class BitImos:
    """
    ・範囲すべての要素に加算
    ・ひとつの値を取得
    の2種類のクエリをO(logn)で処理
    """
    def __init__(self, n):
        self.bit = Bit(n+1)

    def add(self, s, t, x):
        # [s, t)にxを加算
        self.bit.add(s, x)
        self.bit.add(t, -x)

    def get(self, i):
        return self[i]

    def __getitem__(self, key):
        # 位置iの値を取得
        return self.bit.sum(key)


N, K = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(K)]

bit = BitImos(N+2)
bit.add(1, 2, 1)

mod = 998244353

for i in range(1, N+1):
    cur = bit.get(i) % mod
    for l, r in LR:
        if i + l > N:
            continue
        bit.add(i+l, min(i + r + 1, N + 2), cur)

print(bit.get(N) % mod)


Measured memory_bytes: 79008
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    # dp[i][0 or 1]:=1.上からi桁目までぴったり払える最小の枚数, 2.i桁目を1余分に払っている
    S = list(map(int, '0'+input()))
    l = len(S)
    dp = [[1e18]*2 for _ in range(1001001)]
    dp[0][0]=0
    for i in range(l):
        k = S[i]
        dp[i+1][0] = min(dp[i+1][0], dp[i][0]+k) # 1の位そのまま
        dp[i+1][1] = min(dp[i+1][1], dp[i][0]+k+1) # 1の位に1加える
        dp[i+1][0] = min(dp[i+1][0], dp[i][1]+10-k) # 上の桁で1余分に払っているのでお釣りが出る
        dp[i+1][1] = min(dp[i+1][1], dp[i][1]+10-k-1) # 1の位も1余分に払うのでお釣りが1減る
    print(dp[l][0])

    
if __name__ == "__main__":
    main()

Measured memory_bytes: 214976
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
a = l()
print(max(a)-min(a))

Measured memory_bytes: 77428
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
using ll = long long;
using ld = long double;
#define vpl vector<pair<long long,long long>>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
using pll = pair<long long,long long>;
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
const long long INF = 1LL << 60;
long long MOD = 1000000007;
const long double pi = 3.1415926535897932;
#define pb push_back
#define mp make_pair
#define mt make_tuple
//(mod m)でのaの逆元を計算する
//a/b(mod m)=a(mod m)*modinv(b,m)
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

//最大最小の入れ替え
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;
}

//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
//コンビネーション
ll nCr(ll n, ll r) {
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (ll i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}
//素因数分解
map< ll, ll > prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

//切り上げの割り算は(a + b - 1) / bでできる

//ここから
int main(){
    ll N;
    cin>>N;
    vl A(N);
    vl B(N);
    rep(i,N)cin>>A[i]>>B[i];
    ll count=0;
    rep(i,N){
        ll x=B[N-1-i]-A[N-1-i]%B[N-1-i];
        if(x==B[N-1-i]&&count==0){
            continue;
        }else if(x>=count){
            count=x;
        }else{
            ll y=(count-x+B[N-1-i]-1)/B[N-1-i];
            x+=B[N-1-i]*y;
            count=x;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 1792
N = int(input())
h = []
for i in range(N):
    h.append(list(map(int, input().split(" "))))

cost = h[-1]

for day in range(N-2, -1, -1):
    today_cost = []
    today_cost.append(h[day][0] + max(cost[1], cost[2]))
    today_cost.append(h[day][1] + max(cost[0], cost[2]))
    today_cost.append(h[day][2] + max(cost[0], cost[1]))
    cost = today_cost

print(max(cost))


Measured memory_bytes: 30580
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> p(n), q;
    for (auto &e : p) std::cin >> e;
    for (int i = 0; i < n; i++) {
        if (p[i] != i + 1) q.push_back(i);
    }

    if (q.size() <= 2) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = str(input())
b = str(input())
c = str(input())
count = 0
for i in range(n):
  if a[i] == b[i] and b[i] == c[i]:
    continue
  elif a[i]== b[i] or a[i]==c[i] or b[i]==c[i]:
    count += 1
  else:
    count+=2
print(count)

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

using namespace std;

int main( ) {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	string a,b,c;
	t = 1;
	while(t--) {
	 cin >> a >> b >> c;
	 a[0] = a[0] - 32;
	 b[0] = b[0] - 32;
	 c[0] = c[0] - 32;
	 cout << a[0] << b[0] << c[0] << endl;
	}
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int A, B;
	cin >> A >> B;
	if(1 <= A && A <= 9 && 1 <= B && B <= 9)
		cout << A * B;
	else
		cout << -1;
	return 0;
}

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

int main() {
    while(1){
        int H, W;
        cin >> H >> W;
        if (H == 0 && W == 0){
            break;
        }
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}

Measured memory_bytes: 1156
N,M=map(int,input().split())
ab=[list(map(int,input().split())) for _ in [0]*M]
g=[set() for _ in [0]*N]
[g[b-1].add(a-1) for a,b in ab]
[g[a-1].add(b-1) for a,b in ab]
a=g[0]
for i in a:
	if N-1 in g[i]:
		print('POSSIBLE')
		break
else:
	print('IMPOSSIBLE')

Measured memory_bytes: 117432
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main() {
	int n;
	string s;
	cin>>n>>s;
	int ans=1;
	for(int i=0;i<n-1;i++){
		if(s[i]!=s[i+1]) ans++;
	}
	cout<<ans<<endl;
}

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

#define DEBUG(C) cerr << #C << " = " << C << endl

using namespace std;

const int INF = 1e9;
const int MAX = 111;
set<int> floze;
int dist[MAX][MAX];
vector<pair<int, int>> graph[MAX];
using state = tuple<int, int, int>;
// keika, nokori, now town

void solve(int n) {
  for (int i = 0; i < MAX; i++) {
    graph[i].clear();
    for (int j = 0; j < MAX; j++) {
      dist[i][j] = INF;
    }
  }
  floze.clear();
  int m, l, k, start, goal;
  scanf("%d%d%d%d%d", &m, &l, &k, &start, &goal);
  floze.insert(start);
  floze.insert(goal);
  for (int i = 0; i < l; i++) {
    int buf;
  	scanf("%d", &buf);
  	floze.insert(buf);
  }
  for (int i = 0; i < k; i++) {
  	int x, y, t;
  	scanf("%d%d%d", &x, &y, &t);
  	graph[x].emplace_back(make_pair(y, t));
  	graph[y].emplace_back(make_pair(x, t));
  }
  priority_queue<state, vector<state>, greater<state>> pq;
  pq.push(make_tuple(0, m, start));
  dist[start][m] = 0;
  while (!pq.empty()) {
//    DEBUG(pq.size());
    int now, keika, nokori;
    tie(keika, nokori, now) = pq.top();
    pq.pop();
    if (dist[now][nokori] < keika) {
      continue;
    }
    if (floze.count(now)) {
      for (int i = nokori + 1; i <= m; i++) {
        if (dist[now][i] > keika + i - nokori) {
          dist[now][i] = keika + i - nokori;
          pq.push(make_tuple(keika + i - nokori, i, now));
        }
      }
    }
    for (auto e : graph[now]) {
      if (nokori - e.second < 0) {
        continue;
      }
      if (dist[e.first][nokori - e.second] <= keika + e.second) {
        continue;
      }
      dist[e.first][nokori - e.second] = keika + e.second;
      pq.push(make_tuple(keika + e.second, nokori - e.second, e.first));
    }
  }
  int ans = INF;
  for (int i = 0; i < MAX; i++) {
    ans = min(ans, dist[goal][i]);
  }
  if (ans == INF) {
    puts("Help!");
  } else {
    printf("%d\n", ans);
  }
}

int main() {
  while (true) {
    int n;
    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    solve(n);
  }
  return 0;
}

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

#define rep(i, n) for(int i=0;i<(int)(n);++i)

using namespace std;

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;
}

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

using ll = long long;
using P = pair<int, int>;

const unsigned long long INF = 1LL << 60;

////////////////////////////////////////////////////////////

int r, c;
int a[101][101];

int main() {
    cin >> r >> c;
    rep(i, r) rep(j, c) cin >> a[i][j];

    for (int i = 0; i < r; i++) {
        int sum = 0;
        for (int j = 0; j < c; j++) {
            sum += a[i][j];
            printf("%d ", a[i][j]);
        }
        printf("%d\n", sum);
    }

    int total = 0;
    for (int j = 0; j < c; j++) {
        int sub = 0;
        for (int i = 0; i < r; ++i) {
            sub += a[i][j];
        }
        printf("%d ", sub);
        total += sub;
    }
    printf("%d\n", total);
}



Measured memory_bytes: 3244
import sys

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    P = [int(p) - 1 for p in input().split()]
    C = [int(c) for c in input().split()]

    roopCount = [0] * N
    for i in range(N):
        index = i
        for j in range(N):
            if P[index] == i:
                roopCount[i] = j + 1
                break
            else: 
                index = P[index]

    maxPoint = -10 ** 20
    for i in range(N):
        visited = [-10 ** 14] * N
        point = 0
        index = i
        count = K
        while count > 0:
            index = P[index]
            if visited[index] == -10 ** 14:
                point += C[index]
                visited[index] = point
                count -= 1
            else:
                point += C[index]
                if point <= visited[index]:
                    maxPoint = max(maxPoint, max(visited))
                    break
                else:
                    count -= 1
                    add = point - visited[index]
                    visited[index] = point
                    
                    roop = count // roopCount[index]
                    visited[index] += add * roop
                    count %= roopCount[index]
                    point = visited[index]
                    for _ in range(count):
                        index = P[index]
                        point += C[index]
                        visited[index] = point
                    maxPoint = max(maxPoint, max(visited))
                    break
        else:
            maxPoint = max(maxPoint, max(visited))

    print(maxPoint)
    #print(roopCount)

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 70860
N = int(input())
play = list()
for i in range (N):
  play.append(input())
X = input()
j = 0
name = list()
time = list()
while j < N:
  kyoku = list(play[j].split())
  name.append(kyoku[0])
  time.append(int(kyoku[1]))
  j += 1

A = 0
k = name.index(X) + 1
while k < N:
  A += time[k]
  k += 1

print(A)

Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <bitset>
using namespace std;

int main() {

    int N; // スイッチ（on / off）
    int M; // 電球 -> K個のスイッチ

    cin >> N >> M ;

    // M 行,  - 列
    vector<vector<int>> data(M, vector<int>());

    // 電球個数ループ
    for (int i = 0; i < M; i++) {

        // スイッチ個数
        int K;
        cin >> K;

        data[i].push_back(K);

        // スイッチ個数ループ
        int k[K];
        for (int j = 0; j < K; j++) {
            cin >> k[j];
            data[i].push_back(k[j]);
        }
    }

    // 電球個数ループ
    int p[M];
    for (int i = 0; i < M; i++) {
        cin >> p[i];
    }

    int cnt = 0;

    // N個のスイッチの、ON/OFF 全組み合わせループ
    for (int tmp = 0; tmp < (1 << N); tmp++) {
        //ビット表現(0000)
        bitset<10> s(tmp);
        //cout << "---------" << s << "---------" << endl;

        int m_on[M];

        // 電球個数ループ
        for (int i = 0; i < M; i++) {

            int ken = data[i][0];
            //cout << (i+1) << " 件目電球:スイッチ " << ken << "個 ループ開始"<<endl;
            int on = 0;

            // スイッチ個数ループ
            for (int j = 1; j <= ken; j++) {
                //cout << "スイッチ番号 :" << data[i][j] << endl;

                //　k[j] ビット目のビット有り
                if (s.test(data[i][j]-1)) {
                    //cout << "スイッチ番号 :" << data[i][j] << " on "<<endl;
                    on++;
                }
            }


            //cout << (i+1) << " 件目:スイッチ " << "on件数 " << on << endl;
            //cout << "P " << p[i] << endl;
            if (p[i] == on % 2){
                m_on[i] = 1;
                //cout << (i+1) << "件目電球 - ON" << endl;
            }
            else{
                //cout << (i+1) << "件目電球 - OFF" << endl;
                m_on[i] = 0;
            
            }
        }
        bool flg = true;
        for (int i = 0; i < M; i++) {
            if (m_on[i] == 0){
                flg = false;
            }
        }
        if(flg){
            //cout << "-----------cnt up" << endl;
            cnt++;
        }
    }

    cout << cnt << endl;


    return 0;

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std ;
int x[200007] ;
int main(){
	int n , h ;
	cin >> n >> h ;
	long long s=0 ;
	for(int i=0 ; i<n ; i++){
	    cin >> x[i] ;
	    s+=x[i] ;
	}
	sort(x,x+n) ;
	for(int i=n-1 ; i>n-h-1 ; i--){
	    s=s-x[i] ;
	    if(s<=0) break ;
	}    
        
    if(s<0)s=0 ;
	cout << s ;
}

Measured memory_bytes: 1024
### global variables

$rots = []
$dscmb = []

### subroutines

def rot_x(d0, n = 1)    # 2:+y->0:+z, 0:+z->3:-y, 3:-y->5:-z, 5:-z->2:+y
  d = d0
  n.times.each{d = [d[2], d[1], d[5], d[0], d[4], d[3]]}
  d
end

def rot_y(d0, n = 1)    # 0:+z->1:+x, 1:+x->5:-z, 5:-z->4:-x, 4:-x->0:+z
  d = d0
  n.times.each{d = [d[4], d[0], d[2], d[3], d[5], d[1]]}
  d
end

def rot_z(d0, n = 1)    # 1:+x->2:+y, 2:+y->4:-x, 4:-x->3:-y, 3:-y->1:+x
  d = d0
  n.times.each{d = [d[0], d[3], d[1], d[4], d[2], d[5]]}
  d
end

def gen_all_rot()
  d = (0..5).map{|i| i}

  # top=0
  4.times.each {yield d; d = rot_z(d);}
  # top=1 1:+x->0:+z
  d = rot_y(d, 3)
  4.times.each {yield d; d = rot_z(d);}
  d = rot_y(d)
  # top=2 2:+y->0:+z
  d = rot_x(d)
  4.times.each {yield d; d = rot_z(d);}
  d = rot_x(d, 2)
  # top=3 3:-y->0:+z
  4.times.each {yield d; d = rot_z(d);}
  d = rot_x(d)
  # top=4 4:-x->0:+z
  d = rot_y(d)
  4.times.each {yield d; d = rot_z(d);}
  d = rot_y(d)
  # top=5 5:-z->0:+z
  4.times.each {yield d; d = rot_z(d);}
  d = rot_y(d, 2)
end

def check_cube(pos, ds, rs, used)
  return true if pos >= 8

  b = 1

  for i in (0..7)
    if (used & b) == 0
      for r in $rots
        if (pos & 1) != 0
          pos0 = pos - 1
          next if ! $dscmb[ds[pos0]][rs[pos0][1]][i][r[4]]
        end
        if (pos & 2) != 0
          pos0 = pos - 2
          next if ! $dscmb[ds[pos0]][rs[pos0][2]][i][r[3]]
        end
        if (pos & 4) != 0
          pos0 = pos - 4
          next if ! $dscmb[ds[pos0]][rs[pos0][0]][i][r[5]]
        end

        if check_cube(pos + 1, ds + [i], rs + [r], used | b)
          return true
        end
      end
    end

    b <<= 1
  end

  false
end

### main

$rots = []
gen_all_rot(){|r| $rots << r}

while true
  d = gets.strip
  break if d == '0'

  ds = [d.split('').map{|s| s}]

  7.times.each do
    d = gets.strip.split('').map{|s| s}
    ds << d
  end

  $dscmb = 8.times.map{6.times.map{8.times.map{6.times.map{false}}}}

  for i in (0..7)
    for isd in (0..5)
      ch = ds[i][isd]
      ch0 = (ch >= 'A' && ch <= 'Z') ? (ch.ord + 32).chr : (ch.ord - 32).chr

      for j in (0..7)
        next if i == j
        for jsd in (0..5)
          if ds[j][jsd] == ch0
            $dscmb[i][isd][j][jsd] = true
          end
        end
      end
    end
  end

  tf = false

  for r in $rots
    tf = check_cube(1, [0], [r], 1)
    break if tf
  end

  puts (tf ? "YES" : "NO")
end

Measured memory_bytes: 6428
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp12
{
    class Class1
    {
        static void Main()
        {
            string[] str = Console.ReadLine().Split();
            int A = int.Parse(str[0]);
            int B = int.Parse(str[1]);

            int R = A - B * 2;
            if (R < 0)
                R = 0;
            Console.WriteLine(R);
        }
    }
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    ll X,K,D;
    cin >> X >> K >> D;
    ll ans;
    ll dist = max(X,-X);
    if (dist/D>K) {
        ans = dist - K*D;
    }
    else {
        K -= dist/D;
        dist %= D;
        if (K%2==0) ans = dist;
        else {
            dist = dist - D;
            ans = -dist;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 3644
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    in cnt=0ll;
    if(k==0){
        cout<<(in)n*n<<endl;
        return 0;
    }
    REP(b,k+1,n+1){
        in a=(in)(n+1-b)/b;
        cnt +=(a+1ll)*(b-k);
        if((a+1)*b+k>n) continue;
        in thet=(in)n-k-(a+1)*b;
        cnt +=thet+1ll;
    }
    cout<<cnt<<endl;
}
//./problem.exe

Measured memory_bytes: 256
using System;
using System.Linq;

class Contest {
  static void Main() {
    var input = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
    var N = input[0];
    var K = input[1];
    var h = Console.ReadLine().Trim().Split(' ').Select(x => int.Parse(x)).ToArray();
    
    int count = 0;
    for(var i = 0; i < N; i++) {
     	if(h[i] >= K) {
          count++;
        }
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 19296
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    メイン処理.

    Args:\n
        N (int): 正整数(2 <= N <= 10**6)
    """
    # 求解処理
    ans = 0
    for a in range(1, N):
        ans += math.floor((N - 1) / a)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N = get_input()

    # メイン処理
    main(N)


Measured memory_bytes: 9184
#include <iostream>
#include <vector>

int main() {
  unsigned N;
  std::cin >> N;
  std::vector<std::pair<unsigned long long, unsigned>> a(N);
  for (unsigned i = 0; i < N; ++i) {
    std::cin >> a[i].first;
    a[i].second = i + 1;
  }
  //後ろから見る
  std::sort(a.begin(), a.end(),
            [](std::pair<unsigned long long, unsigned> i,
               std::pair<unsigned long long, unsigned> j) -> bool {
              return i.first < j.first;
            });
  std::vector<unsigned long long> ans(N + 1, 0);
  unsigned long long multi = 1;
  while (!a.empty()) {
    while (a.size() > 1 && (a.end() - 1)->first == (a.end() - 2)->first) {
      (a.end() - 2)->second = std::min((a.end() - 1)->second, (a.end() - 2)->second);
      ++multi;
      a.pop_back();
    }
    if (a.size() > 1) {
      ans[(a.end() - 1)->second] += multi * ((a.end() - 1)->first - (a.end() - 2)->first);
      (a.end() - 2)->second = std::min((a.end() - 1)->second, (a.end() - 2)->second);
      ++multi;
      a.pop_back();
    } else {
      ans[a.front().second] += multi * a.front().first;
      a.pop_back();
    }
  }
  for (unsigned i = 1; i <= N; ++i) {
    std::cout << ans[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3456
#include<cstdio>
#include<complex>

#define Re real()
#define Im imag()

using namespace std;

typedef complex<double> Point;
typedef complex<double> Vector;

double dot(const Point& a, const Point& b)
{
    return (conj(a)*b).Re;
}

double cross(const Point& a,const Point& b)
{
    return (conj(a)*b).Im;
}

int main()
{
    int vol;
    double x1,x2,y1,y2;
    while(~scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2))
    {
        Point p0 = Point(x1,y1),p1 = Point(x2,y2);
        Vector v0 = p1 - p0;
        scanf("%d",&vol);
        while(vol--)
        {
            double tx,ty;
            scanf("%lf%lf",&tx,&ty);
            Point Pn = Point(tx,ty);
            Vector v1 = Pn - p0;
            double ans = cross(v1,v0);
            if(ans < 0) printf("COUNTER_CLOCKWISE\n");
            else if(ans > 0) printf("CLOCKWISE\n");
            else
            {
                int tmp = dot(v1,v0);
                if(tmp < 0) printf("ONLINE_BACK\n");
                else
                {
                    if(norm(v1) > norm(v0)) printf("ONLINE_FRONT\n");
                    else printf("ON_SEGMENT\n");
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1068
import heapq
from collections import defaultdict

INF = 1e21

N = int(input())
Adj_list = defaultdict(set)

for _ in range(N-1):
    a, b, c = map(int, input().split())
    Adj_list[a-1].add((b-1,c))
    Adj_list[b-1].add((a-1,c))

Q, K = map(int, input().split())

def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)] # (distance, v)の順。一般的にヒープは(key, 要素)のタプルをpush, popする。
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u] + c, v))
                
    return d

distance = dijkstra(N, K-1)

for i in range(Q):
    x, y = map(int, input().split())
    print(distance[x-1] + distance[y-1])

Measured memory_bytes: 73336
#include<iostream>
using namespace std;
long long N;
int main(){
    cin>>N;
    long long A[N],dp[N]={1000LL};
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=1;i<N;i++){
        dp[i]=dp[i-1];
        for(int j=0;j<i;j++)dp[i]=max(dp[i],A[i]*(dp[j]/A[j])+(dp[j]%A[j]));
    }
    cout<<dp[N-1]<<endl;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
char s[N];
int main() {
	scanf("%s", s);
	int n = strlen(s);
	ll ans = 0, cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'B') cnt++;
		else ans += cnt;
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, K, A[212345], m1mod[212345], sum[212345];

int main() {

	cin >> N >> K;
	rep(i, N) cin >> A[i];
	rep(i, N) m1mod[i] = (A[i] - 1) % K;
	sum[0] = 0;
	rep(i, N) sum[i + 1] = (sum[i] + m1mod[i]) % K;
	map<int, int> counts, counts_2;
	counts[0]++;
	ll ans = 0;
	rep(i, N) {
		ans += counts[sum[i + 1]];
		if (i - K + 1 >= 0) {
			counts_2[sum[i - K + 1]]++;
			ans -= counts_2[sum[i + 1]];
		}
		counts[sum[i + 1]]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 14464