akhauriyash/Code-Regression huggingface dataset:
#![allow(dead_code)]
use std::io;

fn main() {
    solve_d();
}

fn solve_d() {
    let mut x = String::new();

    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<i32> = x.trim()
        .split(' ')
        .map(|s| s.parse::<i32>().unwrap())
        .collect();

    let w = v[0];
    let h = v[1];
    let x = v[2];
    let y = v[3];
    let r = v[4];
    if x + r <= w && 0 <= x - r && 0 <= y - r && y + r <= h {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5024
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
string S;

int main() {
  INCANT;
  cin >> S;
  int N = S.size();
  int cnt = 0;
  int rest=0;
  rep(i, N) {
    if (rest>0 && S[i]=='T') {
      rest--;
      cnt++;
    }
    else if (S[i]=='S') rest++;
  }

  cout << N-cnt*2 << "\n";
  return 0;
}

Measured memory_bytes: 720
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;

struct edge
{int u,v,next;
};
struct edge e[6010];

int n,num;
int a[6010],f[6010],head[6010];
vector<int> ans;

void add(int u,int v)
{e[num].u=u;
 e[num].v=v;
 e[num].next=head[u];
 head[u]=num;
 num++;
}

int calc(int i)
{int j;
 
 if(f[i]!=-1) return f[i];
 
 f[i]=0;
 j=head[i];
 while(j!=-1)
 {	if(calc(e[j].v)==0)
 		f[i]=1;
 	j=e[j].next;
 }
 return f[i];
}

int main()
{int i,j,x,y;
 
 scanf("%d",&n);
 for(i=1;i<=n;i++) scanf("%d",&a[i]);
 memset(head,-1,sizeof(head));
 for(i=1;i<n;i++)
 {	scanf("%d%d",&x,&y);
 	if(a[x]>a[y])
 		add(x,y);
 	else if(a[y]>a[x])
 		add(y,x);
 }
 memset(f,-1,sizeof(f));
 for(i=1;i<=n;i++)
	if(calc(i)==1) ans.push_back(i);
 for(i=0;i<ans.size();i++)
 {	printf("%d",ans[i]);
 	printf("%c",i!=ans.size()-1?' ':'\n');
 }
 return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,aa,b,c,cmp,cmpp,m,k,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n >> k;
       rrep(i,k+1,n+1){
           pos=i;//b
           a=n/pos;
           //Cout(a);
           if(pos-k>0){
               a*=pos-k;
              // Cout(a);
           }
           else{
               a=0;
           }
           if(n%pos-k+1>0){
               aa=n%pos-k+1;
              // Cout(aa);
           }
           else{
               aa=0;
           }
           ans+=aa+a;
         //  Cout(ans);
       }
       if(k==0){
       Cout(ans-n);
       }
       else{
           Cout(ans);
       }
       
return 0;
}


Measured memory_bytes: 256
N=int(raw_input())
H=[int(x) for x in raw_input().split()]
C=[0 for x in range(N)]
C[1]=abs(H[0]-H[1])
for i in range(2,N):
    C[i]=min(C[i-1]+abs(H[i]-H[i-1]), C[i-2]+abs(H[i]-H[i-2]))
print C[-1]


Measured memory_bytes: 12164
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

using namespace std;

inline int max(int a, int b) {//最大
	if (a > b) return a;
	return b;
}

int n, h[100005],ans=0,max1=0;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	for (int i = 0; i < n; i++) {
		while (h[i]>=h[i+1] && i<n-1) {
			max1++;
			
			i++;
		}
		ans=max(max1, ans);
		max1 = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

// a=b (mod k)
// a=c (mod k)

signed main() {
    ll n,k;
    cin>>n>>k;
    map<ll,ll> m; // {x,y}: 法kのもとで、値xがy個存在する
    rep(a,1,n+1)
        m[a%k]++;
    ll ans=0;
    rep(a,0,k){
        ll b = (k-a)%k;
        ll c = (k-a)%k;
        if ((b+c)%k!=0)
            continue;
        ans += m[a]*m[b]*m[c];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,M;
    cin >> N >> M;
    int sum = 1900*M + 100*(N - M);
    int power = 1; for(int i = 0; i < M; ++i) power *= 2;
    cout << sum*power << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
template <typename T>
bool chmax(T &u, const T z)
{
    if (u < z)
    {
        u = z;
        return true;
    }
    else
        return false;
}
template <typename T>
bool chmin(T &u, const T z)
{
    if (u > z)
    {
        u = z;
        return true;
    }
    else
        return false;
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
typedef pair<ll, ll> P;
const ll INF = 1LL << 60;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

int main()
{
    int n, q;
    cin >> n >> q;
    fenwick_tree<ll> fw(n);
    rep(i, n)
    {
        int a;
        cin >> a;
        fw.add(i, a);
    }
    rep(i, q)
    {
        int b;
        cin >> b;
        if (b == 0)
        {
            int p;
            ll x;
            cin >> p >> x;
            fw.add(p, x);
        }
        else
        {
            int l, r;
            cin >> l >> r;
            ll ans = fw.sum(l, r);
            cout << ans << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 8208
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    ll N;
    cin >> N;
    vector<int> ans;
    int cur = 1;
    
    
    while(N >= (1LL << (cur + 1)) - 1){
        cur++;
    }
//    output(cur);
//    output((1LL << cur) - 1);
    ll dist = N - (1LL << cur) + 1;
//    cout << "dist:" << dist <<  endl;
    
    rep(i, cur) ans.pb(i + 1);
    rep(i, cur){
        if((dist & (1LL << (cur - i - 1))) > 0) ans.pb(cur + i + 1);
    }
    
//    voutput(ans);
    
    rep(i, cur){
        if((dist & (1LL << i)) > 0) ans.pb(2 * cur - i);
        ans.pb(i + 1);
    }
    
    output(ans.size());
    voutput(ans);
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int decode(string s){
    int ans =0;
    int ch = 1;
    for (int i=0; i<s.length(); i++) {
        if (s[i]=='m') ans += 1000*ch;
        if (s[i]=='c') ans += 100*ch;
        if (s[i]=='x') ans += 10*ch;
        if (s[i]=='i') ans += ch;
        if(s[i]!='m' and s[i]!='c' and s[i]!='x' and s[i]!='i'){
            ch = (int)s[i]-(int)'0';
        }else{
            ch = 1;
        }
    }
    return ans;
}

string code(int n){
    int m = n/1000, c=(n-m*1000)/100, x=(n-m*1000-c*100)/10, i=n-m*1000-c*100-x*10;
    string ans="";
    if (m>0) {
        if(m==1){
            ans+="m";
        }else{
            ans += (char)((int)'0'+m);
            ans += "m";
        }
    }
    if (c>0) {
        if(c==1){
            ans+="c";
        }else{
            ans += (char)((int)'0'+c);
            ans += "c";
        }
    }
    if (x>0) {
        if(x==1){
            ans+="x";
        }else{
            ans += (char)((int)'0'+x);
            ans += "x";
        }
    }
    if (i>0) {
        if(i==1){
            ans+="i";
        }else{
            ans += (char)((int)'0'+i);
            ans += "i";
        }
    }
    return ans;
}


int main(){
    int we;
    cin >> we;
    for(int qw=0;qw<we;qw++){
        string a,b;
        cin >> a >> b;
        int A = decode(a);
        int B = decode(b);
        int C = A+B;
        cout <<code(C)<<endl;
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int H1, M1, H2, M2, K;

int main(void) {

	cin >> H1 >> M1 >> H2 >> M2 >> K;
	cout << (H2 * 60 + M2) - (H1 * 60 + M1) - K << endl;

	return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,i,k;
    cin>>a;
    int ar[a];
    cin>>k;
    for(i=0; i<a; i++)
    {
        cin>>ar[i];
    }
    sort(ar,ar+a);

     int sum=0;

     for(i=0; i<k; i++)
    {
        sum+=ar[i];
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3604
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{

		Scanner sc = new Scanner(System.in);
		String AtCoDeer = sc.next();
		String TopCoDeer = sc.next();

		if(AtCoDeer.equals(TopCoDeer)){
			System.out.println("H");
		}else {
			System.out.println("D");
		}
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    ll A, B; cin >> A >> B;
    ll g = __gcd(A, B);
    vector<ll> a;
    for (ll i = 1; i * i <= g; i++) {
        if (g % i == 0) {
            for (ll j : {i, g / i}) {
                if (a.empty() || j != a.back()) {
                    a.push_back(j);
                }
            }
        }
    }
    sort(a.begin(), a.end());
    map<ll, bool> used;
    ll res = 0;
    for (ll x : a) {
        bool good = true;
        for (ll i = 1; i * i <= x && good; i++) {
            if (x % i == 0) {
                for (ll j : {i, g / i}) {
                    if (used[j] && j > 1) {
                        good = false;
                    }
                }
            }
        }
        if (good) {
            res++;
            used[x] = true;
        }
    }
    cout << res << "\n";
}


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

ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(){
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll E = lcm(C , D);
    ll ca = (A - 1) / C; ll cb = B / C; ll c = cb - ca; 
    ll da = (A - 1) / D; ll db = B / D; ll d = db - da;
    ll ea = (A - 1) / E; ll eb = B / E; ll e = eb - ea;
    cout << B - (A - 1) - (c + d - e) << endl;
}

Measured memory_bytes: 256
ns = input()

if ns[0] == ns[1]:
    if ns[0] != ns[2]:
        if ns[2] == ns[3]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

elif ns[0] == ns[2]:
    if ns[1] == ns[3]:
        print("Yes")
    else:
        print("No")
elif ns[0] == ns[3]:
    if ns[1] == ns[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	LL N,M;
	cin >> N >> M;
	cout << abs(N-2) * abs(M-2) << endl;

	return 0;
}



Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H,W = map(int,readline().split())
S = ''.join(read().decode().split())

INF = 10 ** 9
N = H*W
U = 250
dp = [[INF] * U for _ in range(N)]
# そのマスをいじる回数 → 総回数の最小値
dp[0] = list(range(U))
for n in range(H*W):
    for i in range(U-1,0,-1):
        if dp[n][i-1]> dp[n][i]:
            dp[n][i-1] = dp[n][i]
    for i in range(1,U):
        if dp[n][i-1] + 1 < dp[n][i]:
            dp[n][i] = dp[n][i-1] + 1
    s = S[n]
    if s == '#':
        for i in range(0,U,2):
            dp[n][i] = INF
    else:
        for i in range(1,U,2):
            dp[n][i] = INF
    x,y = divmod(n,W)
    to = []
    if y < W - 1:
        to.append(n+1)
    if x < H - 1:
        to.append(n+W)
    for m in to:
        for i in range(U):
            if dp[m][i] > dp[n][i]:
                dp[m][i] = dp[n][i]

print(min(dp[-1]))

Measured memory_bytes: 66652
import java.util.*;
public class Main{
 
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int C=sc.nextInt();
		int K=sc.nextInt();
		int[] T=new int[N];
		for(int i=0;i<N;i++){
		T[i]=sc.nextInt();
		}
		Arrays.sort(T);
		
		int wait=1;
		int waitTime=T[0];
		int result=1;
		for(int i=1;i<N;i++){
			if(wait==C||T[i]-waitTime>K){
				result++;
				wait=0;
				waitTime=T[i];
			}
			wait++;
		}
		System.out.println(result);

	}
 
}


Measured memory_bytes: 53792
<?php
  fscanf(STDIN, "%d%d", $x, $n);
  $p = explode(" ", trim(fgets(STDIN)));
  if(!in_array($x,$p)){
      echo $x;
      exit;
  }
  
  $a = 1;
  $ans = [];
  while(1){
      if(!in_array($x+$a,$p)){
          $ans[] = $x+$a;
      }
      if(!in_array($x-$a,$p)){
          $ans[] = $x-$a;
      }
      
      $a++;
      
      if(count($ans) > 0){
          echo min($ans);
          exit;
      }
  }
  


Measured memory_bytes: 16204
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll = long long;
using ull = unsigned long long;

static const int MOD = (1e+9) + 7;

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

    vector<vector<ll>> dp(
        S.size() + 1, vector<ll>(13, 0)
    );

    dp[0][0] = 1;

    for (int i = 0; i < S.size(); ++i) {
        int c;
        if (S[i] == '?') {
            c = -1;
        } else {
            c = S[i] - '0';
        }

        for (int j = 0; j < 10; ++j) {
            if (c != -1 && c != j) {
                continue;
            }

            for (int k = 0; k < 13; ++k) {
                dp[i+1][(k * 10 + j) % 13] = (dp[i+1][(k * 10 + j) % 13] + dp[i][k]) % MOD;
            }
        }
    }

    ll ans = dp[S.size()][5];
    cout << ans << endl;

    return 0;
}


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

int main(){
	long long n;
	int ans = 0;
	scanf("%lld", &n);
	for (long long i = 2; i * i <= n; i++){
		if (n % i == 0){
			int cnt = 0;
			while (n % i == 0){
				cnt++;
				n /= i;
			}
			for (int j = 1; j <= cnt; j++){
				ans++;
				cnt -= j;
			}
		}
	}
	if (n > 1)
		ans++;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3712
//

#include "stdio.h"

int main(){
	char s[200001], t[200001];
	char rs[26], rt[26];
	scanf("%s\n", s);
	scanf("%s\n", t);
	for (int i = 0; i < 26; i++){
		rs[i] = -1;
		rt[i] = -1;
	}
	for (int i = 0; s[i]; i++){
		if (rs[s[i] - 'a'] < 0) {
			rs[s[i] - 'a'] = t[i];
		}
		else {
			if (rs[s[i] - 'a'] != t[i]) {
				printf("No\n");
				return 0;
			}
		}
		if (rt[t[i] - 'a'] < 0) {
			rt[t[i] - 'a'] = s[i];
		}
		else {
			if (rt[t[i] - 'a'] != s[i]) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
  if (a < b) std::swap(a, b);
  if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
  llong g = gcd(a, b);
  return a * b / g;
}
//ここまで共通
int main() {
	int N;
	cin >> N;
	bool F = false;
	for (int i = 1; i <= 9; i++) {
		if (N % i == 0 && 1 <= N / i && N / i <= 9) {
			F = true;
		}
	}
	if (F) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i < b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = INT_MAX / 2;
const ll  inf = LLONG_MAX / 2;
const int mod = 1000000007;
const int MAX_N = 101010;
const long double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int h, n;
	cin >> h >> n;

	vector<int> a(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
	}

	if (sum >= h) {
		out("Yes");
	}
	else {
		out("No");
	}

	return 0;
}

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

int main(){
  int sum, coin; 
  cin >> sum >> coin;
  
  int rest;
  rest = sum % 500;
  
  if(coin > rest){
    cout << "Yes" << endl;
  }
  else if(rest == coin){
    cout << "Yes" << endl;
  } 
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

template<int SZ> struct Combo {
    ll fac[SZ+1], ifac[SZ+1];
    
    Combo() {
        fac[0] = ifac[0] = 1;
    	FOR(i,1,SZ+1) {
    	    fac[i] = i*fac[i-1] % MOD;
    	    ifac[i] = inv(fac[i]);
    	}
    }
    
    ll po (ll b, ll p) { return !p?1:po(b*b%MOD,p/2)*(p&1?b:1)%MOD; }
    ll inv (ll b) { return po(b,MOD-2); }
    
    ll comb(ll a, ll b) {
        if (a < b || b < 0 || a < 0) return 0;
        ll tmp = fac[a]*ifac[b] % MOD;
        tmp = tmp*ifac[a-b] % MOD;
        return tmp;
    }
};

Combo<200005> C;

int H,W,A,B;

ll ad(ll a, ll b) { return (a+b)%MOD; }
ll sub(ll a, ll b) { return (a-b+MOD)%MOD; }
ll mul(ll a, ll b) { return a*b%MOD; }

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> H >> W >> A >> B;
    ll ans = 0;
    F0R(i,H-A) {
        ans = ad(ans,mul(C.comb(i+B-1,i),C.comb(W-1-B+H-1-i,H-1-i)));
        // 0 to B-1
        // B to W-1
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 3328
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<deque>


#define REP(i,a,b) for(int i = (a); i < b; ++i)
#define inf 1e9+10
#define MOD 1000000007

using ll = long long;
using namespace std;

int main() {
	int x;

	cin >> x;

	if (x) {
		cout << 0;
	}
	else {
		cout << 1;
	}

	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	int A[n];

	for(int i = 0; i < n; i++) scanf("%d",&A[i]);

	for(int i = n-1; i > 0; i--) printf("%d ",A[i]);
	printf("%d\n",A[0]);
}



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

vector<string> term = { "dream", "dreamer", "erase", "eraser" }; //単語群
string S;
bool cnable = true;  //構築可能か否か

/*反転させると、maerd, remaerd, esare, resareとなり、頭文字で判別が容易となる*/

int main(){
  cin >> S;
  int L = S.size();

  for(int i = 0; i < term.size(); i++)
    reverse(term[i].begin(), term[i].end());  //構成要素となる単語の反転

  reverse(S.begin(), S.end());  //検査対象の文字列も反転

  int i = 0;
  while(i < L){
    string s;
    if(S[i] == 'm') s = term[0];
    else if(S[i] == 'e') s = term[2];
    else if(S[i] == 'r'){
      if(S[i+2] == 'm') s = term[1]; 
      else if(S[i+2] == 's') s = term[3]; 
      else { cnable = false; break; }
    } else { cnable = false; break; }
  
    int w = s.size();
    //cout << s << " : " << S.substr(i, w) <<  endl;  
    
    if(i + w - 1 < L && S.substr(i, w) == s) i += w; //i+w-1は文字列終端番号 i含めてj個とる
    else { cnable = false; break; }

    //cout << "------------------------------------" << endl;
  
  } //while

  if(cnable) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

  

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<int> city(N);
  vector<int> bridge(2*M);
  for(int i = 0;i<2*M;i++){
    cin>>bridge.at(i);
    city.at(bridge.at(i)-1)++;
  }
  for(int i = 0;i<N;i++){
    cout << city.at(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <cmath>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
const ll MOD = 998244353;

int main() {
    ll a , b;
    cin >> a >> b;
    if (a > b) {
        cout << -1 << endl;
        return 0;
    }
    for (ll i = 0; i <= 10001; ++i) {
        if ((i * 8) / 100 == a && (i * 10) / 100 == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> pii;
#define INF 0x3f3f3f3f
const int N = 100010;
int mod = 1000000007;
struct Node
{
	int t, x, y;
	void input()
	{
		scanf("%d%d%d", &t, &x, &y);
	}
	bool operator < (const Node &b)const
	{
		return t < b.t;
	}
	bool cmp(const Node &b)
	{
		int all = (abs(b.x - x)+abs(b.y-y));
		int cur = b.t - t - all;
		if (cur >= 0 && (~cur&1))
		{
			return true;
		}
		else
			return false;
	}
}rec[N];
int main()
{
	//freopen("in.txt", "r", stdin);
	int n;
	while (~scanf("%d", &n))
	{
		for (int i = 0; i < n; i++)
		{
			int x, y, t;
			rec[i].input();
		}
		sort(rec, rec + n);
		// int dir[4][2] = {0, 1, 0, -1, 1, 0,-1, 0};
		Node cur;
		cur.x = 0;
		cur.y = 0;
		cur.t = 0;
		bool flag = true;
		for (int i = 0; i < n; i++)
		{
			if (cur.cmp(rec[i]))
				cur = rec[i];
			else
			{
				flag = false;
				break;
			}
		}
		printf("%s\n", flag? "Yes": "No");
	}
   	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cstdio>
using ll = long long;
ll arr[100005], val[100005], ans[100005];
int main()
{
	// freopen("AGC003-E.in", "r", stdin);
	int n, m;
	scanf("%d%d", &n, &m);
	arr[0] = n;
	for (int i = 1; i <= m; i++)
		scanf("%lld", arr + i);
	m = 0;
	for (int i = 0; arr[i]; i++)
	{
		while (m && arr[i] <= arr[m - 1])
			m--;
		arr[m++] = arr[i];
	}
	val[m - 1] = 1;
	for (int i = m - 1; i >= 0; i--)
	{
		ll x = arr[i];
		while (true)
		{
			int pos = std::upper_bound(arr, arr + i, x) - arr - 1;
			if (pos < 0)
				break;
			val[pos] += val[i] * (x / arr[pos]);
			x %= arr[pos];
		}
		if (x)
			ans[x] += val[i];
	}
	for (int i = n; i; i--)
		ans[i] += ans[i + 1];
	for (int i = 1; i <= n; i++)
		printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 3968
#include<stdio.h>
int main()
{
	int n1,n2,x,y;
	scanf("%c %c",&x,&y);
	if(x>60)
	n1=x-55;
	else
	n1=x-'0';
	
	if(y>60)
	n2=y-55;
	else
	n2=y-'0';
	
	if(n1==n2)
	{
	printf("=\n");
	}

	if(n1>n2)
	{
	printf(">\n");
	}
	
	if(n1<n2)
	{
	printf("<\n");
	}

} 

Measured memory_bytes: 128
<?php
$S = trim(fgets(STDIN));  // 入力
$T = trim(fgets(STDIN));  // 入力
$Tplus1 = substr($T, 0, strlen($S));
if ($Tplus1 == $S) {
    echo 'Yes';
} elseif ($Tplus1 != $S) {
    echo 'No';
}

Measured memory_bytes: 16164
n = gets.to_i
cnt = 0
n.times do
  flag = 0
  prime = gets.to_i
  if prime < 4
    cnt += 1
    next
  end
  (2..prime**(1/2.0)).each do |i|
    if prime%i == 0
      flag = 1
      break
    end
  end
  cnt += 1 if flag==0
end

puts cnt


Measured memory_bytes: 6952
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll a,b,c;
    while(cin>>a>>b>>c){
        cout<<(a+b+c)-max(a,max(b,c))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
dem=[]
ans=[]
for i in range(m):
    a,b=map(int,input().split())
    dem.append([a,b])
dem=sorted(dem,key=lambda x:x[1])  
for i in range(m):
    if len(ans)==0:
        ans.append(dem[i][1]-1)
    else:
        if ans[-1]<dem[i][0]:
            ans.append(dem[i][1]-1)  
print(len(ans))

Measured memory_bytes: 22108
require 'pp'

n = gets.to_i
a_n = Array.new(n)
n.times do |i|
    x = gets.chomp!
    a_n[i] = x
end

x = {'AC' => 0, "WA" => 0, "TLE" => 0, "RE" => 0}
a_n.each do |a|
    x[a] += 1
end

x.each do |x, n|
    puts "#{x} x #{n}"
end


Measured memory_bytes: 20492
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n,x,y;
    cin >> n >> x >> y;
    x--; y--;
    vector<int> ans(n-1,0);
    rep(i,n-1){
        for(int j = i+1; j < n; j++){
            int mn = min(j - i, abs(x - i) + abs(y - j) + 1);
            ans[mn - 1]++;
        }
    }
    rep(i,n-1) dunk(ans[i]);
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val aList = readLongList()
    val q = readInteger()

    val tmpArray = LongArray(100001)
    for (a in aList) {
        tmpArray[a.toInt()]++
    }

    var aSum = aList.sum()
    repeat(q) {
        val (b, c) = readLongList()

        val bCount = tmpArray[b.toInt()]
        aSum -= b * bCount
        aSum += c * bCount

        tmpArray[b.toInt()] = 0
        tmpArray[c.toInt()] += bCount

        out.println(aSum)
    }
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 59564
import bisect

n = int(input())
l = list(map(int, input().split()))

l.sort()

ans = 0

for i in range(n):
    for j in range(i+1, n):
        q = l[i]+l[j]
        p = bisect.bisect_left(l, q)
        ans += (p - j - 1)

print(ans)

Measured memory_bytes: 3188
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 200010;
int N;
int A[MAX_N];

int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) cin >> A[i];

  if (A[1] != 0) {
    cout << -1 << endl;
    return 0;
  }

  for (int i = 1; i < N; ++i) {
    if (A[i] + 1 < A[i+1]) {
      cout << -1 << endl;
      return 0;
    }
  }

  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (i == N || A[i] + 1 != A[i+1]) {
      ans += A[i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
<?php
list($n, $a, $b) = ints();
if ($a > $b) exit('0');
if ($a === $b) exit('1');
if ($n === 1) exit('0');
if ($n === 2) exit('1');
echo ($b - $a) * ($n - 2) + 1;
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int kbx,kby,kax,kay,x,y,a,n;

int main()
{
	ios::sync_with_stdio(false);
	cin >> kax >> kay >> n;
	kbx = 0;
	kby = 0;
	for(int i=0;i<n;i++)
	{
		cin >> x >> y >> a;
		if(a==1) kbx = max(x,kbx);
		if(a==2) kax = min(x,kax);
		if(a==3) kby = max(y,kby);
		if(a==4) kay = min(y,kay);
	}
	int luas = 0;
	if(kay>kby&&kax>kbx) luas = (kay-kby)*(kax-kbx);
	cout << luas << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
  {int N, K; cin >> N >> K;
  long long ans = 0;
  for (long long i = K; i <= N + 1; ++i) ans = (ans + i * (N - i + 1) + 1) % 1000000007;
  cout << ans << endl;}

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

int main(){
	int N;
	while (cin >> N){
		if (N == 0) break;
		vector<int>K(N);
		//入力
		for (int i = 0; i < N; i++){
			cin >> K[i];
		}
		//2つ以上ある品物がなければ、条件を満たせない
		bool isOk = false;
		for (int i = 0; i < K.size(); i++){
			if (K[i] >= 2) isOk = true;
		}
		if (!isOk){
			cout << "NA" << endl;;
		}
		else{
			//最悪でダブり無しで全種類引いた後、なんでもよいので何か同じのを引く
			int ans = 0;
			for (int i = 0; i < K.size(); i++){
				//ただし個数が0のものはそもそも引くことができないのでカウントしない
				if (K[i] >= 1) ans++;
			}
			ans++;
			cout << ans << endl;
		}
	}
}

Measured memory_bytes: 1232
# 解説を参考に作成
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(S):
    mod = 10 ** 9 + 7
    dp = [0] * (S + 1)
    dp[0] = 1
    for i in range(3, S + 1):
        dp[i] = dp[i - 1] + dp[i - 3]
        dp[i] %= mod
    print(dp[S])


if __name__ == '__main__':
    S = int(input())
    solve(S)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


Measured memory_bytes: 9092
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  string s;
  R s;
  stack<char> st;
  int ans=0;
  rep(i,s.size()) {
    if(st.size()&&st.top()!=s[i]) {
      st.pop();
      ans+=2;
    } else st.push(s[i]);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 512
from fractions import gcd

n, m = list(map(int, input().split()))
s = input()
t = input()

g = gcd(n,m)
a = n//g
b = m//g
flag = True
for i in range(g):
    if not s[a*i] == t[b*i]:
        flag = False
        break
if flag:
    print(g*a*b)
else:
    print(-1)

Measured memory_bytes: 5432
def binary_search(S, n, index ):
    if S[index] == n:
        return 'eq'
    elif S[index] < n:
        return 'bt'
    elif S[index] > n:
        return 'lt'

n = int(input())
S = [int(i) for i in input().split()]
q = int(input())
T = [int(i) for i in input().split()]

cnt = 0
for i in T:
    mini = 0
    maxi = len(S) - 1
    while int(maxi - mini) >= 0:
        index = int( (mini + maxi) / 2 )
        rs = binary_search(S, i, index )
        if rs == 'eq':
            cnt += 1
            break
        elif rs == 'bt':
            mini = index + 1
        elif rs == 'lt':
            maxi = index - 1

print(cnt)

Measured memory_bytes: 18820
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(void){
    double a, b, x;
    cin >> a >> b >> x;
    double ok = 0, ng = 90;
    for(int i=0;i<1000;i++){
        double mid = (ok + ng) / 2;
        double t = tan(mid * M_PI / 180);
        double lim = 0;
        if(a*t < b){
            lim = a*a*(b-a*t/2);
        }else{
            double c = b / t;
            lim = c*b*a/2;
        }
        if(x <= lim)ok = mid;
        else ng = mid;
    }
    cout << fixed << setprecision(16) << ok << endl;
}


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



int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++) cin >> a[i];
    ll mod=1e9+7;
    ll b[n];
    b[0]=1;
    b[n-1]=a[n-1];
    for(ll i=n-2;i>0;i--){
        b[i]=b[i+1]+a[i];
        b[i]%=mod;
    }
    ll res=0;
    for(ll i=0;i<n-1;i++){
        res+=(a[i]*b[i+1])%mod;
        res%=mod;
    }
    cout << res << endl;
}  


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    vector<int> dp(n);
    for (int i = 1; i < n; ++i) {
        dp[i] = dp[i - 1] + abs(h[i - 1] - h[i]);
        if (i >= 2) {
            dp[i] = min(dp[i], dp[i - 2] + abs(h[i - 2] - h[i]));
        }
    }
    cout << dp.back() << '\n';
    return 0;
}

Measured memory_bytes: 3900
#include <iostream>
#include <cmath>

using namespace std;

typedef long long ll;

ll N,K;

int main(){
  cin >> N >> K;
  ll count = 0;
  for(ll b = K+1;b<=N;b++){
    ll s = N / b;
    ll a = N % b;
    count += s * (b-K);
    if(K != 0) count += max((ll)0,a-K+1);
    else count += a;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
#include "tuple"

#define rep(n) for (int i = 0; i < n; ++i)
#define REP(n,i) for (int i = 0; i < n; ++i)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define mkt make_tuple
#define P pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

ll n, m;
string s, t;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

int main() {
	cin >> n >> m >> s >> t;
	ll l = lcm(n, m);
	map<ll,char>v;
	rep(n) {
		v[l / n*i] = s[i];
	}
	rep(m) {
		if (v.find(l/m*i)!=v.end()&&v[l / m*i] != t[i]) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << l << endl;
	return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n==0) return 0;
    vector<string> e(n);
    for(int i=0;i<n;i++){
      cin >> e[i];
    }
    string s,t="";
    for(int i=0;i<m;i++){
      cin >> s;
      t+=s;
    }
    m=t.length();
    vector<vector<bool>> dp(m+1,vector<bool>(1<<n,false));
    int ans=0;
    for(int i=0;i<m;i++){
      if(dp[i][(1<<n)-1]) ans++;
      dp[i][0]=true;
      for(int j=0;j<n;j++){
        if(i+e[j].length()>m) continue;
        for(int k=0;k<e[j].length();k++){
          if(t[i+k]!=e[j][k]) goto next;
        }
        for(int k=0;k<(1<<n);k++){
          if(!(k&(1<<j))){
            if(dp[i][k]) dp[i+e[j].length()][k+(1<<j)]=true;
          }
        }
        next:
        continue;
      }
    }
    if(dp[m][(1<<n)-1]) ans++;
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 5660
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

constexpr int P = 1000000007;

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

    int n, m;
    cin >> n >> m;

    vector<int> b(n + 1, 0);
    for (int j = 0; j < m; j++) {
        int a;
        cin >> a;

        b[a] = 1;
    }

    vector<int> dp(n + 1);
    dp[0] = 1;
    dp[1] = b[1] ^ 1;
    for (int i = 1; i < n; i++) {
        if (b[i + 1]) continue;
        dp[i + 1] = (dp[i] + dp[i - 1]) % P;
    }

    cout << dp[n] << endl;

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

vector< vector<int> > edge(200004, vector<int>());
ll counter[200004];
bool seen[200004];

void dfs(int node) // search child
{
	if (seen[node])
	{
		return;
	}
	seen[node] = true;

	for(const auto& e : edge[node])
	{
		if (seen[e]) // 親
		{
			counter[node] += counter[e];
			break;
		}
	}

	for(const auto& e : edge[node])
	{
		if (!seen[e]) // 子
		{
			dfs(e);
		}
	}
}

void solve()
{
	fill(counter, counter + 200004, 0);
	fill(seen, seen + 200004, false);

	ll n, q, a, b, p, x;
	cin >> n >> q;

	for(ll i = 0; i < n - 1; ++i)
	{
		cin >> a >> b;
		edge[a].push_back(b);
		edge[b].push_back(a);
	}

	for(ll i = 0; i < q; ++i)
	{
		cin >> p >> x;
		counter[p] += x;
	}

	dfs(1);

	for(int i = 1; i <= n; ++i)
	{
		cout << counter[i] << " ";
	}
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 22184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b

signed main(){
	map<ll,ll> mp;
	ll n; cin>>n;
	ll k; cin>>k;
	rep(i,0,n){
		ll a; cin>>a;
		mp[a]++;
	}
	vl vec(0);
	for(auto c:mp){
		vec.push_back(c.second);
	}
	ll ans=0;
	sort(all(vec));
	reverse(all(vec));
	
	while(vec.size()>k){
		ll m=vec.size();
		ans+=vec[m-1];
		vec.pop_back();
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 17664
#include <stdio.h>

int main(){
	int a;
	int b;

	int num[2];
	scanf("%d",&a);
	scanf("%d",&b);

	if(b >= a){
		printf("%d\n", a);
	} else{
		int c = a - 1;
		printf("%d\n", c);
	}
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(1) {
    int n, k;
    cin >> n >> k;
    if(n == 0 && k == 0) break;

    vector<int> a(n);
    REP(i, n) cin >> a[i];
    
    int ans = 0;
    for(int i = 0; i < k; i++) {
      ans += a[i];
    }
    int mx = ans;
    for(int i = 0; i < n - k; i++) {
      mx = mx + a[k + i] - a[i];
      ans = max(mx, ans);
    }

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


Measured memory_bytes: 3424
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0 ; i<(n) ; ++i)
#define rep1(i,n) for (int i=1 ; i<=(n) ; ++i)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
typedef long long ll;
using namespace std;

int main(){
  ll n;
  cin >> n;
  char s = 'a';

  vector<int> co;
  rep(i,30){ 
    n=n-1;
    int c = n%26;
    n /= 26;
    co.push_back(c);
    if(n==0) break;
  }

  for(int i=0; i<co.size(); i++){
    cout << char('a'+co[co.size()-i-1]);
  }
  cout << endl;
  // if(1<=n && n<=26){
  //   cout << char('a'+n-1) << endl;
  // }else if(27<= n && n <=(26+26*26)){
  //   int a = n/26 ;
  //   int b = n%26 ;
  //    cout << char <<
  // }
  return 0;
}


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

int n,m;
bool vis[21][21];
char a[25][25];
int d[25][25];
int mv[][2]={{0,1},{1,0},{0,-1},{-1,0}};
int BFS(int x,int y){
    memset(vis,0,sizeof(vis));
    vis[x][y]=1;
    d[x][y]=0;
    queue<pair<int,int> > q;
    q.push({x,y});
    int ret=0;
    while(!q.empty()) {
        tie(x,y) = q.front();
        q.pop();
        for (int i=0;i<4;i++) {
            int X = x+mv[i][0];
            int Y = y+mv[i][1];
            if (X<0 || X>=n || Y<0 || Y>=m)continue;
            if (vis[X][Y] || a[X][Y]=='#')continue;
            vis[X][Y]=1;
            d[X][Y]=1+d[x][y];
            ret=max(ret,d[X][Y]);
            q.push({X,Y});
        }
    }
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>m;
    for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) {
            cin>>a[i][j];
        }
    }
    int ret=0;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++) {
            if (a[i][j]=='.') {
                ret = max(ret, BFS(i,j));
            }
        }
    }
    cout<<ret<<endl;
}

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

int main(){
	long long int l, m, n;
	long long int savingMoney;
	bool output = true;

	while(cin >> l, l){
		savingMoney = 0;
		output = true;
		for(int i=1; i <= 12; i++){
			cin >> m >> n;
			savingMoney += m - n;

			if(l <= savingMoney && output){
				cout << i << endl;
				output = false;
			}
			if(i == 12 && savingMoney < l){
				cout << "NA" << endl;
			}
		}

	}
}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int k = Integer.parseInt(br.readLine());
        String[] str = br.readLine().split(" ");
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[1]);
        String result = "NG";
        for (int i = a; i <= b; i++) {
            if (i % k == 0) {
                result = "OK";
                break;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 32384