akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    vector<vector<int>> a, b;
    map<char, int> m;
    for(int i = 0; i < s.size(); i++){
        if(m.count(s[i])){
            a[m[s[i]]].push_back(i);
        }else{
            m[s[i]] = a.size();
            a.push_back(vector<int>(1, i));
        }
    }
    m.clear();
    for(int i = 0; i < t.size(); i++){
        if(m.count(t[i])){
            b[m[t[i]]].push_back(i);
        }else{
            m[t[i]] = b.size();
            b.push_back(vector<int>(1, i));
        }
    }
    if(a == b){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
}

Measured memory_bytes: 2824
module Main where
import Data.List
solve :: [Int] -> (Int,Int)
solve a =
    let list = [b `div` 400 | b <- a,b < 3200]
        ans = nub list
        list' = [b | b<-a,b>=3200]
        second = length ans + length list'
        first = max (length ans)  1
    in (first,second)



main = do
    n <- getLine
    a <- (map read . words) <$> getLine 
    let ans = solve a
    print $ fst ans
    print $ snd ans


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(b);i>(a);--i)
#define eper(i,a,b) for(int i=((int)(a));i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 1e18
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int n;
ll x;
int a[20000], b[20000];
ll ans = INF;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> x;
    rep(i, 0, n) {
        cin >> a[i];
        b[i] = a[i];
    }
    rep(i, 0, n) { 
        ll sum = (ll)i * x;
        rep(j, 0, n) {
            b[j] = min(b[j], a[(j-i+n)%n]);
        }
        rep(j, 0, n) sum += b[j];
        if (ans > sum) ans = sum;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mk make_pair
#define ub upper_bound
#define lb lower_bound
#define inf 1000000009
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() 
{
    fio;
    ll t;
    //cin>>t;
    t=1;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        ll v[n];
        ll w[n];
        for(ll i=0;i<n;i++)
        cin>>w[i]>>v[i];
        
        ll dp[n+1][k+1];
        
        for(ll i=0;i<=n;i++)
        {
            for(ll j=0;j<=k;j++)
            {
                if(i==0 || j==0)
                dp[i][j]=0;
                
                else if(j>=w[i-1])
                dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-w[i-1]]);
                
                else 
                dp[i][j]=dp[i-1][j];
            }
        }
        
        cout<<dp[n][k]<<endl;
    }
   
}


Measured memory_bytes: 79232
#include<iostream>
using namespace std;
int n,a[111],i,j,ans;
int main(){
  cin>>n;
  for(i=1;i<=n;i++)
    cin>>a[i];
  for(i=1;i<=n;i++)
    for(j=1;j<=n;j++)
      ans=max(ans,(a[i]-a[j])*(i!=j));
  cout<<ans;
}

Measured memory_bytes: 256
int b[5];main(i,s){while(1){for(s=i=0;i-5&&scanf("%d",b+i);s|=1<<--b[i++]);if(i=*b<0)return 0;for(;printf("%d\n",s-1&&s-2&&s-4&&s-7?b[i]-(s-5?s-6?0:1:2)?2:1:3)&&++i-5;);}}

Measured memory_bytes: 600
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    sc.close();

    String ans = ("AAA".equals(S) || "BBB".equals(S)) ? "No" : "Yes";
    System.out.println(ans);
  }
}

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

int main() {
  int a,b,c=0;
  cin>>a;
  b=a;
  c+=a%10;
  while(a>=10){
    a=a/10;
    c+=a%10;
  }
  if(c==1&&b>1){
    cout<<10<<endl;
  }
  else{
    cout<<c<<endl;
  }
}

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

const int inf=0x3f3f3f3f;
using namespace std; 
int main()
{
  ios::sync_with_stdio(false); 
  cin.tie(0); 
  int n,k; 
  cin>>n>>k;
  vector <int> a(n);  
  for (int i=0; i<n; i++) cin>>a[i]; 
  vector <int> dp(n, inf); dp[0]=0; 
  for (int i=0; i<n; i++){
    for (int j=1; j<=k && (i+j)<n; j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));   
    }
  }
  cout<<dp[n-1]<<"\n"; 
  return 0; 
}

Measured memory_bytes: 1024
a,b,c,d = map(int,input().split())

while a > 0 and c > 0:
    c -= b
    if c <= 0:
        ret = 1
    else:
        a -= d
        if a <= 0:
            ret = 2

if ret == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9064
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    ll a,b,c,k;
    while(cin>>a>>b>>c>>k)
    {
        ll sum=0;
        sum=min(a,k);
        k-=min(a,k);
        if(k>0)k-=b;
        if(k>0)sum-=k;
        cout<<sum<<"\n";
    }
    return 0;
}
 









 




























Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
 
mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
 
  string s;
  cin>>s;
  int ans=0;
  rep(i,4){
    if(s[i]=='+')ans++;
    else ans--;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 125568
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n - 1; i >= 0; i--)
#define REP2(i, n, k) for(ll i = 0; i < n; i += k)



ll f(ll n) {
	ll r = 0, s = 0, c = 0;
	if (n > 0) {
		while (s < n) {
			s += pow(4, c);
			c++;
		}
		return (c - 1) * 2;
	}
	else {
		while (s > n) {
			s -= pow(4, c) * 2;
			c++;
		}
		return c * 2 - 1;
	}
}

int main() {
	ll n;
	cin >> n;

	string ans(65, '0');
	while (n) {
		if (n > 0) {
			ll t = f(n);
			n -= pow(4, t / 2);
			ans[t] = '1';
		}
		else {
			ll t = f(n);
			n += pow(4, t / 2) * 2;
			ans[t] = '1';
		}
	}

	for (ll i = ans.size() - 1; i >= 1; i--) {
		if (ans[i] == '0')ans.erase(ans.begin() + i);
		else break;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}

Measured memory_bytes: 256
command = gets.chomp.split("")
#p command
s = Array.new(10)
i = 0
command.each do |c|
  case c
  when '1' then
    s[i] = '1'
    i += 1
  when '0' then
    s[i] = '0'
    i += 1
  when 'B' then
    i -= 1 if i != 0
  end
end

i.times do |i|
  print s[i]
end

puts


Measured memory_bytes: 1788
#include <iostream>

using namespace std;

int main() {
    int m, f, mf, r, n = 0;
    char res;
    while (true) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        mf = m + f;
        res = 'A';
        if (mf < 80) res = 'B';
        if (mf < 65) res = 'C';
        if (mf < 50 && r < 50) res = 'D';
        if (mf < 30 || m == -1 || f == -1) res = 'F';
        cout << res << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<ll> s;
	REP(i, 4) {
		ll n;
		cin >> n;
		s.insert(n);
	}
	if(s.count(1) && s.count(9) && s.count(7) && s.count(4)) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}

/* --------------------------------------- */


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

using namespace std;

#define ll long long
#define ld long double
#define P pair<ll, ll>

#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

#define all(v) v.begin(), v.end()

#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

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

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll r, d, x;
  cin >> r >> d >> x;

  rep(i, 10) {
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}


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

int main() {
        int h, w;
        scanf("%d%d", &h, &w);
        vector<vector<int>> need(10, vector<int> (10));
        for (int i = 0; i < 10; i ++) {
                for (int j = 0; j < 10; j ++) {
                        scanf("%d", &need[i][j]);
                }
        }
        for (int k = 0; k < 10; k ++) {
                for (int i = 0; i < 10; i ++) {
                        for (int j = 0; j < 10; j ++) {
                                need[i][j] = min(need[i][j], need[i][k] + need[k][j]);
                        }
                }
        }
        int ans = 0;
        for (int i = 0; i < h; i ++) {
                for (int j = 0; j < w; j ++) {
                        int a;
                        scanf("%d", &a);
                        if (a == -1) continue;
                        ans += need[a][1];
                }
        }
        printf("%d\n", ans);
        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 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)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

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

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

	ll res = 0;
	int r = 0;
	int sum = 0;
	for (int l = 0; l < n; l++) {
		while (r < n && (sum ^ a[r]) == (sum + a[r])) {
			sum += a[r];
			r++;
		}
		res += r - l;
		if (l == r) r++;
		else sum -= a[l];
	}

	out(res);

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner

object Main extends App{

  val sc = new Scanner(System.in)

  val s = sc.next

  val front = s.substring(0, s.length/2)
  val back  = s.substring(s.length/2).reverse

  val res = (front zip back).count{t => t._1 != t._2}

  println(res)


}

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

int main()
{
    const std::string str_false = "Hoshino";
    const std::string str_true = "Hoshina";

    u_int num_of_data;
    std::string text;
    std::cin >> num_of_data;
    std::cin.ignore();
    
    for(u_int i = 0; i < num_of_data; ++i){
        getline(std::cin, text);
        int index =  0;
        
        while((index = text.find(str_false, index)) != std::string::npos)
            text.replace(index, str_false.size(), str_true);
        std::cout  << text << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1212
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

n,k=get_i
if k<n
    puts 0
    exit
end
MOD=10**9+7
ans=1
k.downto(k-n+1) do|x|
  ans*=x 
  ans%=MOD
end
puts ans


Measured memory_bytes: 8920
#include<iostream>
#include<vector>
#include<string>
#include<math.h> 
#include<algorithm> 
#include<stdio.h> 
#include<sstream>
#include<fstream>  
using namespace std; 
typedef long long ll; 
typedef long double ld; 


char nl = '\n'; 
char bl = ' ';
const int MOD = 1e9 + 7; 

int main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL); 
vector<int> fi; 
vector<int> se; 

int n; 
cin >> n;
 
 for(int i = 0; i<n; i++){
     int a,b; 
     cin >> a >> b; 
     fi.push_back(a);
     se.push_back(b); 
 }


 int cnt = 0; 
 int maxs = -1; 

if(fi[0] == se[0]) cnt = 1; 

for(int i = 1; i<n; i++){
    if(fi[i] == se[i]) {
        cnt++;
    }  
    else{

        cnt = 0; 
    }
            maxs = max(cnt, maxs); 
}

cout << (maxs >= 3 ? "Yes": "No"); 








}



Measured memory_bytes: 3648
#include<stdio.h>
int main(void){
  	int k;
  int a,b;
  scanf("%d\n%d%d",&k,&a,&b);
  int i = (b / k) * k;
  if(a <= i){
    	printf("OK");
  }else{
		printf("NG");
  }
  return 0;
}
  


Measured memory_bytes: 1732
A = []
for _ in range(3):
    A.append(list(map(int, input().split())))
N = int(input())
b = []
for _ in range(N):
    b.append(int(input()))

for num in b:
    for x in range(3):
        for y in range(3):
            if A[x][y] == num:
                A[x][y] = -1

amount = 0
for x in range(3):
    if max(A[x]) == -1:
        amount += 1
for y in range(3):
    if max([A[0][y], A[1][y], A[2][y]]) == -1:
        amount += 1
if max([A[0][0], A[1][1], A[2][2]]) == -1:
    amount += 1
if max([A[2][0], A[1][1], A[0][2]]) == -1:
    amount += 1

if amount > 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
# 初期入力
import sys
input = sys.stdin.readline

A,B,C,D = (int(x) for x in input().split())
while 0 <A and 0 <C:
         
    C -=B
    if 0 <C:
        A -=D
if 0 <A:
    print("Yes")
else:
    print("No")

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

int main()
{
	int n;cin>>n;
	string s;cin>>s;
	int l=0,r=n-1,count=0;
	while(l<r) {
		while(l<r && s[l]=='R') l++;
		while(l<r && s[r]=='W')	r--;
		if(l<r)	count++,l++,r--;
	}
	cout<<count<<"\n";
	return 0;
}


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

using namespace std;

const int Mod = 998244353, Lim = 5e5;
typedef long long ll;

int n, k, i, fact[Lim+4], ifact[Lim+4];
ll ans = 0;

int inm(int x, int y) { return (ll)x*y%Mod; }
int comb(int n, int k)
{
    if(n<k || k<0) return 0;
    return inm( fact[n], inm(ifact[k], ifact[n-k]) );
}

int ways(int x, int y, int lim)
{
    if(lim < 0) return 0;
    return comb(x+y, x) - comb(x+y, y-lim-1);
}

int power(int a, int b)
{
    int ans = 1;
    while(b)
    {
        if(b&1) ans = inm(ans, a);
        a = inm(a,a); b >>= 1;
    }
    return ans;
}

int main()
{
//    freopen("input", "r", stdin);
 //   freopen("output", "w", stdout);
    cin.sync_with_stdio(false);

    cin >> n >> k;
    fact[0] = ifact[0] = 1;
    for(i=1; i<=Lim; ++i) fact[i] = inm(fact[i-1], i);
    ifact[Lim] = power(fact[Lim], Mod-2);
    for(i=Lim-1; i; --i) ifact[i] = inm(ifact[i+1], i+1);

    if(k%2 == 0) ans = ways(k/2, k/2-1, k/2-n);

    for(i=k/2+1; i<=k; ++i)
        ans += ways(i, k-i, i-n);

    ans %= Mod; if(ans < 0) ans += Mod;
    cout << ans % Mod << '\n';
    return 0;
}


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

int main()
{
  ll x,y;cin>>x>>y;
  if (x%y==0)
  {
    cout << -1 << endl;
  }
  else
  {
    cout << x << endl;
  }
  
  
}

Measured memory_bytes: 3588
N,M = map(int, input().split())
L_R = []
for _ in range(M):
    L_R.append(list(map(int, input().split())))
    
l_min = 0
r_max = N
for l,r in L_R:
    if l_min <l:
        l_min = l
    if r_max > r:
        r_max =r
    

if r_max >= l_min:
    print(r_max - l_min + 1)
else:
    print(0)

Measured memory_bytes: 27340
#include <bits/stdc++.h>
using namespace std;
long long N, M;
int main(void){
	cin >> N >> M;
	if(N < M) swap(N, M); // N > M
	if(M == 1){
		if(N > 2) cout << N - 2 << endl;
		else if(N == 1) cout << 1 << endl;
		else cout << 0 << endl;
	}
	else cout << (N - 2) * (M - 2) << endl;
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int temp = a;
	bool can = false;
	do
	{
		if (temp%b == c) {
			can = true;
			break;
		}
		//cout << temp << endl;
		temp += a;
		//i++;
		temp %= b;
	}while(temp != a%b);

	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
	//cin >> a;
}

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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define x first
#define h second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
using pt = pair<int,int>;
 
int n, m, k;
pt a[N];
vector < int > vx;

ll s[N];


int main () {
	SpeedForce;
	cin >> n >> m >> k;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].x >> a[i].h;
		vx.pb(a[i].x);
	}
	sort(a + 1, a + n + 1);
	sort(every(vx));
	//vx.resize(unique(every(vx)) - vx.begin());

	for (int i = 1; i <= n; i ++) {
		a[i].x = i-1;
	}
	ll sum = 0;
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		sum += s[a[i].x];
		if (sum >= a[i].h) continue;
		int r = upper_bound(every(vx), vx[a[i].x] + 2 * m) - vx.begin();
		ll need = (a[i].h - sum + k - 1) / k;
		ans += need;
		//cout << a[i].h - sum << ' ' << sum << ' ' << need << '\n';
		need *= k;
		sum += need;
		s[r] -= need;
	}

   	cout << ans << '\n';
   	return Accepted;
}

// B...a

Measured memory_bytes: 6772
n = gets.split[0].to_i
c = gets.split.map &:to_i
m = (0..n+1).to_a

for i in 2..n
  for j in c.select{|e| e <= i }
    if m[i-j]+1 < m[i]
      m[i] = m[i-j]+1
    end
  end
end

puts m[n]

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(x) ((int) x.size())
#define all(x) (x).begin(), (x).end()
#define re return
#define mp make_pair
#define makeunique(x) sort(all(x)), x.resize(unique(all(x)) - x.begin())
#define endl '\n'

typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef vector<string> vs;

template <class T> T abs (T x) { re x > 0 ? x : -x; }
template <class T> T sqr (T x) { re x * x; }

const double pi = acos(-1.);
const ll inf = 1e18 + 7;
const int N = 3e5 + 17;

int n, m, k;
vii g[2 * N];
int was[2 * N];
ll ans[2 * N];

bool dfs(int v, int c) {
	bool ok = 1;
	was[v] = c;
	for (auto x : g[v]) {
		if (was[x.fi]) {
			if (ans[x.fi] + ans[v] != x.se) re false;	
		} else {
			ans[x.fi] = x.se - ans[v];
			ok &= dfs(x.fi, c);
		}
	}
	re ok;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> m;
	cin >> k;
	for (int i = 0; i < k; i++) {
		int l, r, x;
		cin >> l >> r >> x;
		l--; r--; r += n;
		g[l].pb({r, x});
		g[r].pb({l, x});
	}
	bool ok = 1;
	int c = 1;
	for (int i = 0; i < n + m; i++)
		if (!was[i]) {
			ok &= dfs(i, c);
			c++;
		}
	if (!ok) { cout << "No"; re 0; }
	vll minx(c, inf), miny(c, inf);
	for (int i = 0; i < n + m; i++) {
		auto color = was[i];
		if (i < n) minx[color] = min(minx[color], ans[i]);
		else miny[color] = min(miny[color], ans[i]);
	}

	for (int i = 1; i < c; i++) {
		ll x = minx[i], y = miny[i];
		if (min(x, y) >= 0) continue;
		if (x > y) swap(x, y);
		if (y < abs(x)) ok = 0;
	}
	cout << (ok ? "Yes" : "No");
}


Measured memory_bytes: 32088
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<iomanip>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const ll INF=1e18;


int main()
{
    queue<ll> que;
    for(int t=1;t<10;t++)
    {
        que.push(t);
    }
    ll k;
    cin>>k;
    ll p=0;
    for(ll i=0;i<k;i++)
    {
        p=que.front();
        que.pop();
        if(p%10!=0)
        {
            que.push(10*p+p%10-1);
        }
        que.push(10*p+p%10);
        if(p%10!=9)
        {
            que.push(10*p+p%10+1);
        }


    }
    cout<<p;

    

}

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

int main(){
    string s;
    cin>>s;
    int ans=0;
    int lg=0;
    while(lg+1<=s.size()){
        for(int i=0;i<s.size()-lg;i++){
            int tmp=0;
            rep(j,lg+1){
                if(s[i+j]=='A'||s[i+j]=='T'||s[i+j]=='G'||s[i+j]=='C'){
                    tmp++;
                }
            }
            if(tmp==lg+1) ans=max(ans,tmp);
        }
        lg++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3524
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

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




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

int main(){
  int x[100], i = 0;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      i--;
      x[i-1] = x[i] + x[i-1];
    } else if ( s[0] == '-' ){
      i--;
      x[i-1] = x[i-1] - x[i];
    } else if ( s[0] == '*' ){
      i--;
      x[i-1] = x[i] * x[i-1];
    } else {
      x[i] = atoi(s);
      i++;
    }
  }
  printf("%d\n", x[0]);

  return 0;
}



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

int kai(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main(){
    //n:町の数
    int n;
    cin >> n;
    //za:インデックスに+1番目に対応する町のx,y座標をペアーで持つmap
    vector<pair<double, double>> za(n);
    for(int i = 0; i < n;i++){
        cin >> za[i].first >> za[i].second;
    } 


    //v:町を回る順番
    vector<int> v(n);
    for(int i = 0; i < n; i++){
        v[i] = i;
    }
    //全周り方の距離の合計
    double sum_dis = 0;
    do{
        //ある周り方の距離の合計
        double dis = 0;
        for(int i = 0; i < n-1; i++){
            dis += sqrt(pow((za[v[i]].first - za[v[i+1]].first),2) + pow((za[v[i]].second - za[v[i+1]].second),2));
        }
        sum_dis += dis;
    }while(next_permutation(v.begin(),v.end()));

    double ans = sum_dis / kai(n);
    cout << fixed << setprecision(10)<<ans << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt

readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine

getIntList = readIntList <$> BS.getLine

main = do
  [a, b, c, d] <- getIntList
  let cl = b `div` c - (a -1) `div` c
  let dl = b `div` d - (a -1) `div` d
  let l = lcm c d
  let ll = b `div` l - (a -1) `div` l
  print $ (b - a + 1) - (cl + dl - ll)


Measured memory_bytes: 3780
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int T = sc.nextInt();
        int kotae = 0;
        for(int i=1; i<T+1; i++){
            if(i%A==0){
                kotae = kotae + B;
            } else{
                kotae = kotae;
            }
        }
        System.out.println(kotae);
    }
}

Measured memory_bytes: 23764
import java.util.*;
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int x = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
		
		if(Math.abs(x-a) > Math.abs(x-b)) System.out.println("B");
		else System.out.println("A");
	}

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const ll mod = 1e9 + 7;
const int N = 110, K = 1e5 + 5;
int a[N], n, k;
ll dp[N][K];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		ll pref[k + 1];
		pref[0] = dp[i - 1][0];
		for (int j = 1; j <= k; j++) {
			pref[j] = (pref[j - 1] + dp[i - 1][j]) % mod;
		}
		for (int j = 0; j <= k; j++) {
			ll t = pref[j];
			int val = j - a[i] - 1;
			if (val >= 0) {
				t -= pref[val];
			}
			if (t < 0) {
				t += mod;
			}
			dp[i][j] = t;
		}
	}
	cout << dp[n][k];
	
	return 0;
}


Measured memory_bytes: 87040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int H,W; cin >> H >> W;
    int U[H][W],D[H][W],L[H][W],R[H][W];
    char c[H][W]; rep(i,H) rep(j,W) cin >> c[i][j];
    rep(i,H){
        rep(j,W){
            if(c[i][j] == '#') L[i][j]=0;
            else if(j==0) L[i][j]=1;
            else L[i][j] = L[i][j-1]+1;
        }
    }
    rep(i,H){
        per(j,W){
            if(c[i][j] == '#') R[i][j]=0;
            else if(j==W-1) R[i][j]=1;
            else R[i][j] = R[i][j+1]+1;
        }
    }
    rep(i,W){
        rep(j,H){
            if(c[j][i] == '#') U[j][i]=0;
            else if(j==0) U[j][i]=1;
            else U[j][i] = U[j-1][i]+1;
        }
    }
    rep(i,W){
        per(j,H){
            if(c[j][i] == '#') D[j][i]=0;
            else if(j==H-1) D[j][i]=1;
            else D[j][i] = D[j+1][i]+1;
        }
    }
    int ans=0;
    rep(i,H){
        rep(j,W){
            if(c[i][j]=='#') continue;
            ans=max(ans,U[i][j]+R[i][j]+L[i][j]+D[i][j]-3);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 129152
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
#include<queue>
#include<deque>
using namespace std;
typedef pair<int, int>P;
typedef pair<int, pair < int, int > > PP;
typedef long long ll;
ll inf = -1;
ll mod = pow(10, 9) + 7;

int main() {
	int n,a,b;cin>>n>>a>>b;
	cout<<min(b,a*n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>
//#include <bits/stdc++.h>

template<typename T> bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}

template<typename T> bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}

using namespace std;
#define ALL(X) X.begin(),X.end()
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=2147483647;
const ll LLMAX=9223372036854775807;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll a(N-1),b(N-1),c(N-1);
    vvvll cost(N);
    for(ll i=0;i<N-1;i++){
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;b[i]--;
        cost[a[i]].push_back(vll{b[i],c[i]});
        cost[b[i]].push_back(vll{a[i],c[i]});
    }
    ll Q,K;
    cin>>Q>>K;
    K--;
    vll x(Q),y(Q);
    for(ll i=0;i<Q;i++){
        cin>>x[i]>>y[i];
        x[i]--;y[i]--;
    }
    
    vll distance(N,-1);
    distance[K]=0;
    vll open;
    open.push_back(K);
    while(open.size()>0){
        ll node=open[0];
        open.erase(open.begin());
        for(ll i=0;i<cost[node].size();i++){
            if(distance[cost[node][i][0]]==-1){
                distance[cost[node][i][0]]=distance[node]+cost[node][i][1];
                open.push_back(cost[node][i][0]);
            }
        }
    }
    
    for(ll i=0;i<Q;i++){
        cout<<distance[x[i]]+distance[y[i]]<<endl;
    }
    
    return 0;
}


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

int main(){
	int N,M;
	cin >> N >> M;
	int loop;
	vector<int> H(N);
	for(loop=0;loop<N;loop++){
		cin >> H[loop];
	}
	vector<int> GoodH(N,1);
	int A,B;
	for(loop=0;loop<M;loop++){
		cin >> A >> B;
		if(H[A-1]<H[B-1]){
			GoodH[A-1]=0;
		}else if(H[A-1]>H[B-1]){
			GoodH[B-1]=0;
		}else{
			GoodH[A-1]=0;
			GoodH[B-1]=0;
		}
	}
	int ans=0;
	for(loop=0;loop<N;loop++){
		if(GoodH[loop]){
			ans+=1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3996
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

int N, A;

int main() {
	scanf("%d %d", &N, &A);
	printf("%d\n", (N - A) + 1);	
	return 0;
}
/*
	Powered by Buggy Plugin
*/


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

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


if n == 1 and m == 1:
    corner = 1
    edge = 0
    other = 0
    print(1)
elif n == 1 or m == 1:
    corner = 2
    edge = n*m-corner
    other = 0
    print(edge)
else:
    corner = 4
    edge = n*2+m*2-corner*2
    other = n*m - edge-corner
    print(other)


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    string ans;
    switch (n%10)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        ans = "hon";
        break;
    case 0:
    case 1:
    case 6:
    case 8:
        ans = "pon";
        break;
    case 3:
        ans = "bon";
        break;
    }

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

Measured memory_bytes: 3580
from math import log, floor
from itertools import accumulate, chain, islice, repeat
 
k = int(input())
 
def f(n):
    ds = range(int(log(n+1, 10))+2)
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=lambda n:(n / sum(map(int, str(n))), n))
 
snukes = chain(range(1, 9), accumulate(repeat(9), lambda x,_:f(x+1)))

for x in islice(snukes, k):
    print(x)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PA pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e16+7;
const ll MOD=1e9+7;

int main(){
	ll N,P,ans=0,score=0;
	cin >> N >> P;
	vector<ll> w(N),b(N);
	priority_queue<ll> Q;
	FOR(i,0,N)cin>>w[i]>>b[i];
	FOR(i,0,N)Q.push(w[i]*(100-P)+b[i]*P);
	FOR(i,0,N)score -= b[i]*P;
	while(score<0){
		score += Q.top();
		Q.pop();
		ans++;
	}
	cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  char s[n];
  bool flag = false;
  for(int i = 0; i < n; i++){
    cin >> s[i];
    if(s[i] == 'Y')
      flag = true;
  }
  if(flag)
    cout << "Four" << endl;
  else
   cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll n,a;
    cin >> n >> a;
    cout << (n%500<=a?"Yes\n":"No\n");
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(void){
	int c5=0,c7=0,a,b,c;
	cin>>a>>b>>c;
	if(a==5)c5++;
	if(a==7)c7++;
	if(b==5)c5++;
	if(b==7)c7++;
	if(c==5)c5++;
	if(c==7)c7++;
	if(c5==2&&c7==1) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,cc,vis[705],col[705],num[705][2],f[2][705],e[705][705];
void dfs(int x,int c)
{
	num[cc][c]++;col[x]=c;vis[x]=1;
	for(int i=1;i<=n;i++)if(x!=i&&!vis[i]&&!e[x][i])dfs(i,c^1);else if(x!=i&&!e[x][i]&&col[i]==c){puts("-1");exit(0);}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;i++){scanf("%d%d",&u,&v);e[u][v]=e[v][u]=1;}
	for(int i=1;i<=n;i++)if(!vis[i])cc++,dfs(i,0);
	f[0][0]=1;
	for(int i=1,b=1;i<=cc;i++,b^=1)
	{
		memset(f[b],0,sizeof(f[b]));
		for(int j=0;j<=n;j++)if(f[b^1][j])f[b][j+num[i][0]]=f[b][j+num[i][1]]=1;
	}
	int ans=1e9;
	for(int i=0;i<=n;i++)if(f[cc&1][i])ans=min(ans,i*(i-1)/2+(n-i)*(n-i-1)/2);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = 100001;
		boolean[] isPrime = new boolean[N];
                isPrime[2] = true;
		for(int i=3;i<N;i+=2) isPrime[i] = true;
		for(int i=3;i<=(int)Math.sqrt((double)N);++i){
			if(isPrime[i]){
				for(int j=i*i;j<N;j+=2*i) isPrime[j] = false;
			}
		}		
		int[] ruiseki = new int[N];
		ruiseki[1] = 0;
		for(int i=3;i<N;i+=2){
			if(isPrime[i]&&isPrime[(i+1)/2]) ruiseki[i]++;
			ruiseki[i] += ruiseki[i-2];
		}
		
		int Q = sc.nextInt();
		for(int i=0;i<Q;++i){
			int l = sc.nextInt()-2;
			if(l<0) l=1;
			int r = sc.nextInt();
			System.out.println(ruiseki[r]-ruiseki[l]);
		}
		return;
	}
}

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

int main()
{
    long long money = 100;
    long long X;
    int ans = 0;
    bool flag = true;
    cin >> X;
    while(flag){
        ans += 1;
        money += money/100;
        if(money >= X){
            cout << ans << endl;
            break;
        }
        
    }
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll i,fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
///*二進数割り算*/div2(ll x,ll y){}
llfor;ll ans=0;////////////////////////////////////////////////////////////
int main(){
 ll n,p;
 cin>>n>>p;
  
 if(n==1||p==1){
  pr(p);return 0;
 } 
 if(n>=40){
  puts("1");
  return 0;
 }
 ll ans=0;
 rep(i,1,p){
  //cout<<i<<" "<<llpow(i,n)<<endl;
  if(llpow(i,n)>p)break;
  if(p%llpow(i,n)==0)ans=max(i,ans);
 }
 
 pr(ans);
return 0;}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n,m;
	cin >> n >> m;
	multiset<int> a;
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin >> tmp;
		a.insert(tmp);
	}

	
	
	for(int i=0;i<m;i++)
	{
		auto itr=a.end();
		itr--;
		int tmp=*itr;
		tmp/=2;
		cerr << tmp << endl;
		//cerr << *itr << endl;
		//cerr << "size : " << a.size() << endl;
		a.erase(itr);
		a.insert(tmp);
	}

	long long cnt=0;
	for(auto it=a.begin();it!=a.end();it++)
	{
		//cerr << *it << endl;
		cnt+=*it;
	}


	cout << cnt << endl;


}


Measured memory_bytes: 4992
from sys import stdin
import math
a, b, x = map(int, stdin.readline().rstrip().split())
if x <= 0.5 * a * a * b:
    print(math.degrees(math.atan(a*b*b/(2*x))))
else:
    print(math.degrees(math.atan((2/(a**3))*(a*a*b-x))))


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

int main(){
string s,t;
  cin >>s>>t;
  string ss = s;
  int tlong = t.size();
  int64_t ans =0;
  int64_t x =0;
  for(int i =0;i<tlong;i++){
    x = ss.find_first_of(t.at(i));
    ss.erase(ss.begin(),ss.begin()+x+1);
    if(ss.size()<s.size()) ss +=s;
    //cout <<x+1<<endl;
    if(x>=0) ans +=x+1;
    else{
    ans = -1;
      break;
    }
  }
  cout << ans;
}

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

int main(){
    int t[10][10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
            cin >> t[i][j];
        }
    }

    int count=0;
    for(int id=0; id<10000; id++){
        vector<int> d(5,0);
        int num = id;
        for(int i=3; i>=0; i--){
            d[i] = num%10;
            num /= 10;
        }
        for(int i=0; i<4; i++){
            d[4] = t[d[4]][d[i]];
        }

        bool miss=false;
        //altering
        for(int i=0; i<5; i++){
            for(int j=1; j<=9; j++){
                vector<int> tmp = d;
                tmp[i] = (d[i]+j)%10;
                int check=0;
                for(int k=0; k<5; k++){
                    check = t[check][tmp[k]];
                }
                if(check == 0){
                    miss=true;
                    i=5; break;
                }
            }
        }
        //transposing
        for(int i=0; i<4; i++){
            if(d[i]==d[i+1]) continue;
            vector<int> tmp = d;
            tmp[i] = d[i+1];
            tmp[i+1] = d[i];
            int check=0;
            for(int k=0; k<5; k++){
                check = t[check][tmp[k]];
            }
            if(check == 0){
                miss=true;
                break;
            }
        }
            
        if(miss) count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3112
#include<stdio.h>
int a[100001];
int com[100001],x[100001],y[100001],b[100001];
int B=325;
int n,q;
void put(int a[100001]);
int min(int a,int b);
void update(int i,int x);
void find(int s,int t);
int main(void){
  put(a);
  int i;
  scanf("%d %d",&n,&q);
  for(i=0;i<q;i++){
    scanf("%d %d %d",&com[i],&x[i],&y[i]);
    if(com[i]==0)
      update(x[i],y[i]);
    else if(com[i]==1)
      find(x[i],y[i]);
  }
  return 0;
}
int min(int a,int b){
  if(a<=b)
    return a;
  else
    return b;
}
void update(int i,int x){
  int j;
  a[i]=x;
  b[i/B]=2147483647;
  for(j=i-i%B;j<min(i-i%B+B,n);j++){
    b[i/B]=min(b[i/B],a[j]);
  }
}
void find(int s,int t){
  int ans=2147483647;
  int j;
  for(j=s;j<=t;){
    if(j%B==0 && j+B<=t-1){
      ans=min(ans,b[j/B]);
      j+=B;
    }else{
      ans=min(ans,a[j]);
      j++;
    }
  }
  printf("%d\n",ans);
}
void put(int a[100001]){
  int i;
  for(i=0;i<100001;i++)
    a[i]=2147483647,b[i]=2147483647;
}

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

int main(){
  int A1,A2,A3;
  
  cin >> A1 >> A2 >> A3;
  if( A1+A2+A3 <= 21){
    cout << "win" << endl;
  }else{
    cout << "bust" << endl;
  }
  
  return(0);
}

Measured memory_bytes: 256