akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){

int a,b,c,d;
cin>>a>>b>>c>>d;

if(c>=a&&c<=b){
if(b>=d)
cout<<abs(d-c);
else if(b<d)
cout<<abs(c-b);	
}
else if(a>=c&&a<=d){
if(b>=d)
cout<<abs(d-a);
else if(b<d)
cout<<abs(b-a);	
}

else
cout<<0;


return 0;
} 


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<algorithm>
#include<string>
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> >
#define vb vector<bool> 
#define vvb vector<vector<bool> >
#define INF 1145141919810
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b:i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
using namespace std;

int main(){
	string k_s,g_s; cin>>k_s>>g_s;
	ll g=0,k=0;
	rep(i,k_s.size()+g_s.size()){
		if((i+1)%2) cout<<k_s[k++];
		else cout<<g_s[g++];
	}cout<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

ri,sum=-1,0
for i in range(M):
    if sum+B[i]<=K:
        ri=i
        sum+=B[i]
    else :
        break

sum2,ans=0,ri+1
for i in range(N):
    sum2+=A[i]
    if sum2>K:
        break
    while ri>=0 and sum2+sum>K:
        sum-=B[ri]
        ri-=1
    ans=max(ans,i+1+ri+1)
print(ans)

Measured memory_bytes: 40560
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <map>
#include <climits>
#include <bitset>
using namespace std;
#define MATH_PI 3.14159265358979323846
int arrNums[1000000] = { 1 };
int main(){
	ios::sync_with_stdio(false);
	int n, k;
	register int i;
	cin >> n >> k;
	for (i = 1; i <= n; ++i){
		arrNums[i] = min(arrNums[i - 1] + k, arrNums[i - 1] * 2);
	}
	cout << arrNums[n] << endl;
endapp:
	//system("pause > nul");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <set>
#include <list>
#include <deque>
#include <map>
#include <queue>
#include <fstream>
#include <cassert>
#include <cmath>
#include <sstream>
#include <time.h>
#include <iomanip>
#include <complex>
#include <unordered_map>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<unsigned, unsigned> ii;
typedef pair<double,double> dd;
typedef pair<char,char> cc;
typedef vector<ii> vii;
typedef long long ll;
typedef pair<ll, ll> l4;
typedef long double ld;
typedef unsigned ui;
#define mp make_pair
#define pb push_back

const int maxn = 2e5+1;
int n, m;
vector<int> g[maxn];
bool vis[maxn];
int main()
{
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= m; ++i)
    {
      int u, v;
      scanf("%d %d", &u, &v);
      g[u].pb(v);
      g[v].pb(u);
    }
  memset(vis, false, sizeof(vis));
  for (int i = 0; i < g[1].size(); ++i)
    vis[g[1][i]] = true;
  for (int i = 0; i < g[n].size(); ++i)
    if (vis[g[n][i]])
      {
	puts("POSSIBLE");
	return 0;
      }
  puts("IMPOSSIBLE");
}


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

int main()
{
    int N;
    int64_t K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A.at(i);
    }
    vector<int> F(N);
    for (int i = 0; i < N; i++)
    {
        cin >> F.at(i);
    }

    sort(A.begin(), A.end());
    sort(F.rbegin(), F.rend());
    int64_t l = -1, r = 1e12;
    while (l + 1 < r)
    {
        int64_t m = (l + r) / 2;
        int64_t k = 0;
        for (int i = 0; i < N; i++)
        {
            k += max((int64_t)0, A.at(i) - m / F.at(i));
        }
        if (k <= K)
        {
            r = m;
        }
        else
        {
            l = m;
        }
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;

int a[200000];
signed main(){
	int n, k, mx = -1;
	scanf("%lld%lld", &n, &k);
	rep(i,n)scanf("%lld", &a[i]);
	rep(i,n)chmax(mx, a[i]);
	int m = a[0];
	rep(i,n){
		while(1){
			if(m == a[i])break;
			if(m > a[i]){
				if(m%a[i] == 0){m = a[i];break;}
				m = m%a[i];
			}
			else{
				if(a[i]%m == 0){break;}
				a[i] = a[i]%m;
			}
		}
	}
	
	if(k <= mx and k%m == 0)printf("POSSIBLE\n");
	else printf("IMPOSSIBLE\n");
	//printf("%lld\n", m);
	return 0;
}




Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;

using ll = long long int; 

void prime(vector<int> &num, int n){
    for(int i=0;i<=n;i++){
        num[i] = 1;
    }
    num[0] = 0;
    num[1] = 0;
    num[2] = 1;

    for(int i=2;i<=sqrt(n);i++){
        if(num[i] == 1){
            for(int j=2;j<=n/i;j++){
                num[i*j] = 0;
            }
        }
    }
}


ll gcd(ll a, ll b) {
  ll tmp;
  if ( b > a) {
    tmp = a;
    a = b;
    b = tmp;
  }
  while (a % b !=0) {
    tmp = b;
    b = a % b;
    a = tmp;
  }
  return b;
}
 
ll lcm(ll a, ll b) {
  return a * b / gcd(a, b);
}

int main(void){
   
    ll a,b,x;
    cin>>a>>b>>x;

    if(a==0){
        cout<<b/x + 1<<endl;
    }else{
        cout<<b/x - (a-1)/x<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
using namespace std;

int main(){
	string a, b;
	int n,pa=0, pb=0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a >> b;
		if (a == b){
			pa++;
			pb++;
		}
		else if (a>b){
			pa += 3;
		}
		else{
			pb += 3;
		}
	}
	cout << pa << " " << pb << endl;
	return 0;
}

Measured memory_bytes: 1212
using System;
using System.Collections.Generic;
using System.Linq;

class Program{


  static int n;
  static int cnt = 0;
  static int guNum = 0;

  static int Main() {

    string nyu;
    nyu = Console.ReadLine();
    n = int.Parse(nyu);

    int[] a = new int[n];
    string[] nya = new string[n];
    nya = Console.ReadLine().Split(' ');

    for (int i = 0; i < n ; i ++){
      a[i] = int.Parse(nya[i]);
      if ( a[i] % 2 == 0) guNum ++;
    }
    int kiNum = n - guNum;
    int maeGu = 0;

    for (int i = 0; i < n; i ++) {
      if ( a[i] % 2 == 0) {
        cnt += (int)Math.Pow(3, n - i - 1) * (int)Math.Pow(2, maeGu);
        maeGu ++;
      }else {
        cnt += (int)Math.Pow(3, n - i - 1) * 2 * (int)Math.Pow(2, maeGu);
      }
    }

    Console.WriteLine("{0}", cnt);

    return 0;
  }

}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
class unionfind {
    vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う
public:
    unionfind(int n) :par(n), rank(n), size_(n, 1) {
        iota(all(par), 0);
    }
    int find(int x) {
        if (par[x] == x)return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y)return;
        if (rank[x] < rank[y])swap(x, y);
        par[y] = x;
        size_[x] += size_[y];
        if (rank[x] == rank[y])rank[x]++;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return size_[find(x)];
    }
};
signed main(){
    int n,m;
    cin >> n >> m;
    vector<pii>edge(m);
    auto uf = unionfind(n);
    vector<int>ans(m);
    for(auto & p : edge) cin >> p.first >> p.second,--p.first,--p.second;
    ans[m-1] = n*(n-1)/2;
    for(int i = m-2; i >= 0;--i){
        auto p = edge[i+1];
        ans[i] = ans[i+1] - (uf.same(p.first, p.second) ? 0LL : uf.size(p.first)*uf.size(p.second));
        uf.unite(p.first, p.second);
    }
    rep(i,m) cout << ans[i] << endl;
}



Measured memory_bytes: 6016
def digit_sum(num:int, base:int) -> int:
    if num < base:
        return num
    else:
        return digit_sum(int(num/base), base) + (num % base)

def judge(n: int) -> int:
    if n < 10:
        return n
    
    else:
        # 先頭の位が1のとき、先頭の1を落として全部9にしたものが候補
        if str(n)[0:1] == '1':
            
            cand_str = "9" * (len(str(n)) - 1)
            cand = int(cand_str)
            
            return max(digit_sum(n,10), digit_sum(cand,10))
        
        # そうでないとき、先頭の位を1小さくする
        else:
            top = n // 10**(len(str(n)) - 1)
            cand_str = str(top-1) + "9" * (len(str(n))-1)
            cand = int(cand_str)
            
            return max(digit_sum(n,10), digit_sum(cand,10))

n = int(input())

ans = judge(n)
print(ans)

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

int main(){
  int n;
  
  cin >> n;
  
  string str = to_string(n);
  
  if(str[str.size() - 1] == '3') cout << "bon" << endl;
  else if(str[str.size() - 1] == '0' || str[str.size() - 1] == '1'
  || str[str.size() - 1] == '6' || str[str.size() - 1] == '8') cout << "pon" << endl;
  else cout << "hon" << endl;
  
  return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll mod = 998244353;



ll N,K;

int main() {
	
	cin >> N >> K;
	cout << N - K + 1 << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
    
// ここから
function main(){
  var primeNumbers = calcPrimeNumbers();

  var i = 0;
  while(c = +input[i++]){
    console.log(primeNumbers[c]);
  }
  
}
   
function calcPrimeNumbers(){
  var max = 49999;
  var primeNumbers = new Int8Array(max + 1);
  var primeCounts = new Int16Array(50001);
   
  // 除外
  primeNumbers[0] = primeNumbers[1] = 1;
  for(var i = 2, maxI = ~~Math.sqrt(max); i <= maxI; i++){
    if(primeNumbers[i]){
      continue;
    }
       
    for(var j = (i<<1); j <= max; j+=i){
      primeNumbers[j] = 1;
    }
  }
   
  var primeNums = new Int16Array(5134);
  var c = 0;
  for(var i = 1; i <= max; i++){
    if(primeNumbers[i])
      continue;
    
    primeNums[++c] = i;
    for(var j = 1; j <= c; j++){
      var sum = i + primeNums[j];
      if(sum > 50000)
        break;
      
      primeCounts[sum]++;
    }
      
  }
     
  return primeCounts;
}

Measured memory_bytes: 13472
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;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 repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
    is >> p.first >>p.second ;
    return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
    rep(i, v.size()) {
        is >> v[i];
    }
    return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
ll mod                = 1e9 + 7;
int main(){
    int n;
    ll ans=1LL;
	bool can = true;
	cin >>n;
	V t(n), a(n);
	VP note(n,mp(1,1));//max,min
	cin >> t >> a;
	ll max = -1LL;
	for (int i = 0; i < n;i++){
        if(chmax(max,t[i])){
			note[i].F = max;
			note[i].S = max;
		}else{
			note[i].F = max;
		}
    }
//	clog << note << endl;
	max = -1LL;
    
	for (int i = n - 1; i >= 0;i--){
        if(chmax(max,a[i])){
            if(note[i].F >=max  and note[i].S  <=max){
				note[i].F = max;
				note[i].S = max;
			}else{
				can = false;
			}
        }else{
			chmin(note[i].F, max);
		}
    }
	//clog << note << endl;
    if(can==false){
		cout << 0 << endl;
	}else{
		rep(i, n) { ans *= (note[i].F - note[i].S + 1);
			ans %= mod;
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 6420
#include <bits/stdc++.h>
#define S second
#define F first
#define pb push_back

using namespace std;

typedef long long llong;

const int MXN = (int)2e5 + 7;
const int MOD = (int)1e9 + 7;
const llong INF = 2e18 + 7;

llong sum;
int n, a[MXN], k;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  cin >> n >> k;
  for(int i = 1; i <= n; i++){
    cin >> a[i];
  }
  sort(a + 1, a + n + 1, greater<int>());
  for(int i = 1; i <= n && k > 0; i++){
    a[i] = 0;
    k--;
  }
  for(int i = 1; i <= n; i++){
    sum += a[i];
  }
  cout << sum;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
 
using namespace std;

int main (){
    int N,k;
	cin >> N >> k;
	
	if(N>=13){
		cout << k << endl;
	}
	else if(N>=6){
		cout << k/2 << endl;
	}
	else{
		cout << "0" << endl;
	}
}

Measured memory_bytes: 256
/*
https://drken1215.hatenablog.com/entry/2020/01/26/225000
勉強させていただいた記事
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<ll>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)

//制限がない時は小さくしていくことを考える

int main(){
    ll H,N;
    cin>>H>>N;
    vi A(N),B(N);
    rep(i,N)cin>>A[i]>>B[i];
    vii dp(N+1,vi(H+1,LongINF));
    rep(i,N)dp[i][0]=0;
    rep(i,N){
        rep(j,H+1){
            //使わない場合
            chmin(dp[i+1][j],dp[i][j]);
            //使う場合
            //遷移先より遷移元の方が小さかったら入れ替え
            chmin(dp[i+1][min(j+A[i],H)],dp[i+1][j]+B[i]);
        }
    }
    cout<<dp[N][H]<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 78592
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String data = scanner.nextLine();
        int posA = 0;
        int posZ = 0;
        boolean foundPosA = false;
        for(int i=0; i<data.length(); i++) {
            if(data.charAt(i) == 'A' && !foundPosA) {
                posA = i;
                foundPosA = true;
            }else if(data.charAt(i) == 'Z'){
                posZ = i;
            }
        }

        String output = data.substring(posA,posZ+1);
        System.out.println(output.length());
    }
}


Measured memory_bytes: 27452
n=input()
L=map(int,input().split())
LL = [4 if l % 4 == 0 else 2 if l % 2 == 0 else 1  for l in L]
import collections
C = collections.Counter(LL)
#print(C,C[2])
if C[4] == C[1]:
  print('Yes')
elif (C[4] + 1) == C[1] and C[2] == 0:
  print('Yes')
elif C[4] < C[1]:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 11100
//IOI 2021

#include <bits/stdc++.h>
using namespace std;

#define pb push_back
#define ff first
#define ss second

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 100 * 1000 + 17;

int n, m, dp[MAXN], col[MAXN], IN[MAXN];
vector<pii> adj[MAXN], adj_in[MAXN];
bool mark[MAXN];
vector<int> topol;
stack<int> topol_tmp;

void check_cyc(int v) {
	col[v] = 1;
	for (auto u : adj[v])
		if (col[u.ff] == 1) {
			cout << "No" << endl;
			exit(0);
		}
		else if (!col[u.ff])
			check_cyc(u.ff);
		else
			;
	col[v] = 2;
}

void dfs_topol(int v) {
	mark[v] = true;
	for (auto i : adj[v])
		if (!mark[i.ff])
			dfs_topol(i.ff);
	topol_tmp.push(v);
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int l, r, d;
		cin >> l >> r >> d;
		IN[r]++;
		adj[l].pb({r, d});
		adj_in[r].pb({l, d});
	}
	for (int i = 1; i <= n; i++)
		if (!col[i])
			check_cyc(i);
	for (int i = 1; i <= n; i++)
		if (!IN[i])
			dfs_topol(i);
	while (topol_tmp.size())
		topol.pb(topol_tmp.top()), topol_tmp.pop();
	for (auto i : topol)
		if (IN[i]) {
			int x = dp[adj_in[i][0].ff] + adj_in[i][0].ss;
			for (auto j : adj_in[i])
				if (dp[j.ff] + j.ss != x) {
					cout << "No" << endl;
					return 0;
				}
			dp[i] = x;
		}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 17972
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i, a, n) for (int i=(a); i<(n); i++)
#define per(i, a, n) for (int i=(a); i>(n); i--)
typedef long long ll;
const int maxn = 2e5+5;
const int mod = 1e9+7;
using namespace std;


void solve() {
	ll x,y; cin >> x >> y;
	rep(i,0,x+1) {
		if (2*i + 4*(x-i) == y) {
			cout << "Yes";
			return;
		}
	}
	cout << "No";
}

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef DEBUG
	freopen("C:\\Users\\Fish_Brother\\Desktop\\in", "r", stdin);
	//freopen("C:\\Users\\Fish_Brother\\Desktop\\out", "w", stdout);
#endif
	//int t; cin >> t; while(t--)
	solve();

	return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;//自动取模2^64 
const double pi=acos(-1.0);
const int mod = 1e9+7; // 998244353;
const int inf = 0x7fffffff;//2^31-1	
const ll INF = 0x7fffffffffffffff;
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
//ll begin_time=clock();    ll end_time=clock();  cout<<"time = "<<end_time-begin_time<<" ms!"<<endl;
//bool operator < (const mmp &a) const{return x<a.x||x==a.x&&y<a.y;}       //map<int,map<int,int> >z;
//map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d %d\n",it->first,it->second);
//ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}  //快速幂取模 
//lower_bound(begin,end,num); 第一个>=num的数字 upper_bound(begin,end,num); 第一个>num的数字,返回地址
//freopen("input.in","r",stdin);     freopen("output.out","w",stdout);      //文件读写提交 
//reverse(s.begin(),s.end());   //翻转字符串        floor(); 向下取整  ceil(); 向上取整
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
//bool isPrime(int n){if(n==2||n==3)return 1;if(n%6!=1&&n%6!=5)return 0;
//int t=sqrt(n);for(int i=5;i<=t;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}//判断素数   


int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ull a,b,c,d,e,f,T;
//	cin>>T;
//	while(T--)
	{
		int q=0;
		cin>>a;c=0;d=9;
		while(a--)
		{
			cin>>b;
			if(b==0)
			{
				c=0;
				d=0;
				continue;
			}
			if(c||(!d))continue;
			if(q==0)
			{
				d=b;
				q=1;
				continue;
			}
			e=1+(int)log10(b);
			f=1+(int)log10(d);
			if(e+f>18)
			{
				if((e+f==19)&&b*d<=1000000000000000000L);
				else if(e+f==20&&b*d==1000000000000000000L);
				else c=1;
			}
			d*=b; 
			if(d>1000000000000000000L)c=1;
		} 
		if(c)cout<<"-1"<<endl;
		else cout<<d<<endl;
		
	}
 
}




Measured memory_bytes: 3984
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;

int main(){
  string N;
  int ans, total = 0;
  istringstream ss;

  cin >> N;

  for(int i = 0; i < N.size(); i++) total += N[i] - '0';

  ss = istringstream(N);
  ss >> ans;

  if(ans % total == 0) cout << "Yes" << endl;
  else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
total = []
num = 0
for i in reversed(range(N+1)):
    num += A[i]
    total.append(num)
total.reverse()
if A[0] == 1 and N == 0:
    print(1)
    exit()
if A[0] != 0:
    print(-1)
    exit()
ans = 1
num = 1
for i in range(1,N+1):
    num = min(2*num, total[i])
    ans += num
    num -= A[i]
    if num < 0:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 20028
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
using namespace std;

int main() {
    int D;
    cin >> D;
    map<int, string>mp = {
        { 22,"Christmas Eve Eve Eve" },
        { 23,"Christmas Eve Eve" },
        { 24,"Christmas Eve" },
        { 25,"Christmas" },
    };

    cout << mp[D] << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=1e5+10;
int a[N],b[N];
int main()
{
	int n,i,l,cnt=0,cnta=0,cntb=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	sort(b+1,b+n+1);
	l=unique(b+1,b+n+1)-b-1;
	if(l==1&&a[1]==0)
	{
		printf("Yes");
		return 0;
	}
	if(n%3||l>3||l==1)
	{
		printf("No");
		return 0;
	}
	if(l==2)
	{
		cnt=0;
		for(i=1;i<=n;i++)
			if(a[i]==0)
				cnt++;
		if(cnt==n/3)
			printf("Yes");
		else
			printf("No");
		return 0;
	}
	else
	{
		if((b[1]^b[2]^b[3])!=0)
		{
			printf("No");
			return 0;
		}
		for(i=1;i<=n;i++)
		{
			if(a[i]==b[1])
				cnta++;
			if(a[i]==b[2])
				cntb++; 
		}	
		if(cnta==cntb&&cnta==n/3)
			printf("Yes");
		else
			printf("No");
	}
	return 0;
 } 

Measured memory_bytes: 1024
#include<stdio.h>
int main(void){
   double t1, t2;
   while ( scanf("%lf %lf", &t1, &t2) != EOF ) {
      if ( t1 < 35.5 && t2 < 71 ) printf("AAA\n");
      else if ( t1 < 37.5 && t2 < 77 ) printf("AA\n");
      else if ( t1 < 40   && t2 < 83 ) printf("A\n");
      else if ( t1 < 43   && t2 < 89 ) printf("B\n");
      else if ( t1 < 50   && t2 < 105) printf("C\n");
      else if ( t1 < 55   && t2 < 116) printf("D\n");
      else if ( t1 < 70   && t2 < 148) printf("E\n");
      else printf("NA\n");
   }
   return 0;
}

Measured memory_bytes: 1756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		
		if(N%1000!=0)System.out.println((N/1000+1)*1000- N);
		else System.out.println(0);
	}
}


Measured memory_bytes: 35748
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
signed main(){
    int n;cin>>n;
    rep(i,0,n){
        int a;cin>>a;
        if(a%2){
            cout<<"first"<<endl;return 0;
        }
    }cout<<"second"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <cmath>

int main()
{
	int s;
	scanf("%d", &s);
	double diff = 1000000000;
    int n, r;
	std::array<int, 100005> a;
	for (int i = 0; i < s; ++i)
	{
		scanf("%d", &a[i]);
	}
    std::sort(a.begin(), a.begin()+s);
	n = a[s - 1];
	for (int i = 0; i < s; ++i)
	{
		if (diff > std::abs(a[i] - n / 2.0))
		{
			diff = std::abs(a[i] - n / 2.0);
			r = a[i];
		}
	}

    printf("%d %d\n", n, r);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;


int main() {
  int n;
  cin >> n;
  int ans=0;
  rep(i,n){
    int a,b;
    cin >> a >>b;
    if(a==b){ans++;}else{ans=0;}
    if(ans==3){cout << "Yes" << endl; return 0;}
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<P> v(n);
    vector<int> pos(n);
    int fact = 1;
    for (int i = 1; i <= n; i++)
    {
        fact *= i;
    }
    rep(i, n)
    {
        cin >> v[i].first >> v[i].second;
        pos[i] = i;
    }
    double res = 0;
    do
    {
        rep(i, n - 1)
        {
            int x = v[pos[i]].first - v[pos[i+1]].first;
            int y = v[pos[i]].second - v[pos[i + 1]].second;
            res+=sqrt(x*x + y*y);
        }
    } while (next_permutation(pos.begin(), pos.end()));
    printf("%.12lf\n", res / fact);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1e5 + 10 ;
char ch [N] ;
int main (){
	scanf ( "%s" , ch );
	int tot = 0 ;
	int l = 0 , r = strlen ( ch ) - 1;
	while ( l<r ){
		if ( ch [l] != ch [r] ){
			if ( ch [l] == 'x' ) {
				tot++ , l++ ;
			}else if ( ch [r] == 'x'){
				tot++ , r-- ;
			}else {
				printf ( "-1" ) ;
				return 0;
			}
		}else{
			l++ , r--;
		}
	}
	printf ("%d" , tot );
	return 0 ;
}

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

int main()
{
	int x,y;
	cin>>x>>y;
	
	if(x==2&&y==2) cout<<"Yes"<<endl;
	else if((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)) cout<<"Yes"<<endl;
	else if((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef vector <ll> vl;
#define second s;
#define first f;

int main(){
    int a=0,b=0;
    cin>>a>>b;
    string aa;
    string bb;
    for (int i=0;i<a;i++)
    {
        aa+=to_string(b);
    }
    for (int i=0;i<b;i++)
    {
        bb+=to_string(a);
    }
    if (aa<bb)
    cout<<aa;
    else cout<<bb;
    
}


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

int K;
vector<long long> A;

int main() {
  scanf("%d", &K);
  for(int i = 0; i < K; ++i) {
    long long a; scanf("%lld", &a); A.push_back(a);
  }
  long long m = 2, M = 2;
  for(int i = K - 1; i >= 0; --i) {
    m = (m + A[i] - 1) / A[i] * A[i];
    M = M / A[i] * A[i];
    if(M < m) { printf("-1\n"); return 0; }
    M += A[i] - 1;
  }
  printf("%lld %lld\n", m, M);
  return 0;
}


Measured memory_bytes: 1400
// 002 A - Range Product 2016/07/31
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    int64 a , b; cin >> a >> b;
    int64 counter=0; bool odd=true;
    for(int i=a ; i <=b ; ++i ){
        if(i==0) { cout << "Zero" << endl; return 0; }
        if(i<0) ++counter;
    }
    if(counter % 2 ==0) odd = false;
    cout << (odd ? "Negative" : "Positive") << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

MAX = 1000005
cnt = [0] * MAX
for x in a:
    if cnt[x] > 2:
        continue
    #cnt配列の各倍数のところに+1
    for i in range(x, MAX, x):
        cnt[i] += 1
ans = 0
for x in a:
    if cnt[x] == 1:
        ans += 1

print(ans)

Measured memory_bytes: 32300
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
#どっかで最悪計算量の入力データを用意する関数を作ろう？
"""
方針
O(1)
"""
#solution:
#潜 影 蛇 手 ! !
N,A,B=pin()
if A==B:
    print(1)
elif A>B or N==1:
    print(0)
else:
    print((N-2)*(B-A)+1)
#print(["NO","YES"][1-cond])
#print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
template <typename T>
inline T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long A,B;
    cin >> A >> B;
    cout << lcm(A, B) << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int N;cin>>N;
  vector<ll> A(N);
  ll sum = 0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    sum += A[i];
  }

  vector<ll> res(N);
  res[0] = sum;
  for(int i=1;i<N-1;i+=2){
    res[0]-=A[i]*2;
  }
  for(int i=1;i<N;i++){
    res[i]=A[i-1]*2-res[i-1];
  }

  for(int i=0;i<N;i++){
    if(i>0)cout<<' ';
    cout<<res[i];
  }
  cout<<endl;

  return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  if(b-2*a<=2*a&&b%2==0&&b-2*a>=0){
    cout << "Yes" << endl;
  }else {
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 3624
x, y = map(int, input().split())
if x == 2 or y == 2:
    print('No')
else:
    m1 = set([1, 3, 5, 7, 8, 10, 12])
    m2 = set([4, 6, 9, 11])
    if (x in m1 and y in m1) or (x in m2 and y in m2):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
for(;scanf("%d",&n),n;printf("%d %d\n",a,b)){
    for(a=b=i=0;i<n;i++){
      scanf("%d%d",&x,&y);
      if(x>y)a+=x+y;
      else if(x<y)b+=x+y;
      else a+=x,b+=x;
    }
  }
  return 0;
}

Measured memory_bytes: 0
def main():
    x = int(raw_input())
    if x > 6:
       if (x - 6) % 11 == 0:
           op1 = (x - 6)/11
           op2 = x/11 + 1
       elif x % 11 == 0 :
           op1 = (x - 6)/11 + 1
           op2 = x/11
       else:
           op1 = (x - 6)/11 + 1
           op2 = x/11 + 1
       return op1+op2
    else:
        return 1
print main()

Measured memory_bytes: 2568
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    ls = []
    for i in range(5):
        n = int(input().rstrip('\n'))
        ls.append([n, 0 if n % 10 == 0 else 10 - n % 10, (n + 10 - 1) // 10 * 10])
    ls.sort(key=lambda x: x[1])
    t = 0
    for i in range(4):
        t += ls[i][2]
    print(t + ls[-1][0])


if __name__ == '__main__':
    solve()


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

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

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

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

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

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

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

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, K;
  cin >> N >> K;
  llvec a(N);
  map<ll, ll> s;
  rep(i, N){
    ll t;cin >> t;
    s[t]++;
  }
  vector<P> v;
  for(auto is : s){
    v.push_back({is.second, is.first});
  }
  sort(ALL(v));
  ll ans = 0;
  rep(i, (ll)v.size()-K){
    ans += v[i].first;
  }
  cout << ans;
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	int point[128]; memset(point, 0, sizeof(point));
	for (int i = 0; i < n * (n - 1) / 2; ++i) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (c > d) point[a] += 3;
		else if (c == d) {
			point[a]++;
			point[b]++;
		}
		else point[b] += 3;
	}
	for (int i = 1; i <= n; ++i) {
		int count = 1;
		for (int i2 = 1; i2 <= n; ++i2) {
			if (point[i] < point[i2]) { count++; }
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 3032
let nil = -1

type tree = { mutable parent : int; mutable child : int; mutable bro : int; mutable depth : int }

let make () = { parent = nil; child = nil; bro = nil; depth = nil }

let set_depth t n =
  let rec root i =
    if i = n then nil
    else if t.(i).parent = nil then i
    else root (i + 1) in
  let rec doit i d =
    t.(i).depth <- d;
    if t.(i).bro <> nil then doit t.(i).bro d;
    if t.(i).child <> nil then doit t.(i).child (d + 1) in
  doit (root 0) 0

let print_tree t =
  t |> Array.iteri (fun i _ ->
    print_string "node "; print_int i;
    print_string ": parent = "; print_int t.(i).parent;
    print_string ", depth = "; print_int t.(i).depth;
    print_string (if t.(i).parent = nil then ", root, [" else if t.(i).child = nil then ", leaf, [" else ", internal node, [");
    let rec print_children c =
      if c <> nil then begin
        if c <> t.(i).child then print_string ", ";
        print_int c;
        print_children t.(c).bro
      end in
    print_children t.(i).child;
    print_string "]\n")

let () =
  let n = Scanf.scanf "%d " (fun i -> i) in
  let t = Array.init n (fun _ -> make ()) in
  for _ = 0 to n - 1 do
    let (id, k) = Scanf.scanf "%d %d " (fun id k -> (id, k)) in
    let left_child = ref 0 in
    for i = 0 to k - 1 do
      let c = Scanf.scanf "%d " (fun i -> i) in
      t.(c).parent <- id;
      if i = 0 then t.(id).child <- c else t.(!left_child).bro <- c;
      left_child := c;
    done;
  done;
  set_depth t n;
  print_tree t

Measured memory_bytes: 13276
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, m[22][22] = {}, i, j, k, o, l=0, z, sam = 0, p, q;
ll a[100005] = {} , inf = 1000000000000;
ll b[100005] = {};

string s[22];
ll t[100005], xx[100005];
char ss,st;
const int MAX =100005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	cin >> n >> k;
	if (n % k == 0)sam = n / k;
	else sam = n / k + 1;

	cout << sam;

	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------
ll n, k;
vector<ll> a, f;
ll sum = 0;

bool check(ll x)
{
    ll rec = 0;
    for (ll i = 0; i < n; i++)
    {
        rec += min(x / f[i], a[i]);
    }
    if (sum - rec <= k)
    {
        return true;
    }
    else
    {
        return false;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    a.resize(n);
    f.resize(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    for (ll i = 0; i < n; i++)
    {
        cin >> f[i];
    }
    sort(ALL(a));
    sort(RALL(f));
    ll ok = 1e12;
    ll ng = -1;
    while (llabs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2;
        if (check(mid))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    cout << ok << endl;
}

Measured memory_bytes: 3328
n, q = map(int, input().split())
S = list(input())
L = [0, 0]
l = 0
for i in range(1, n):
    a = S[i-1]
    c = S[i]
    if a == "A" and c == "C":
        l += 1
    L.append(l)

for _ in range(q):
    l, r = map(int, input().split())
    re = 0
    if L[l] != L[l-1]:
        re = 1
    print(L[r] - L[l-1] - re)


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

using namespace std;

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

  int n;
  cin >> n;

  map<string, int> m;

  int cmd, val;
  string key;
  for (int i = 0; i < n; i++) {
    cin >> cmd;

    switch (cmd) {
      case 0:
        cin >> key >> val;
        m[key] = val;
        break;

      case 1:
        cin >> key;
        try {
          cout << m.at(key) << endl;
        } catch (out_of_range&) {
          cout << 0 << endl;
        }
        break;

      case 2:
        cin >> key;
        m.erase(key);
        break;
    }
  }
}




Measured memory_bytes: 25972
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
   string s;
   cin>>s;
   bool flag=true;
   int a,b,c,d;
   a=s.at(0)-'0';
   b=s.at(1)-'0';
   c=s.at(2)-'0';
   d=s.at(3)-'0';
      rep(j,2){
         b=-b;
         rep(k,2){
            c=-c;   
            rep(l,2){
               d=-d;
               //cout<<b<<c<<d<<endl;
               if(a+b+c+d==7&&flag){
                   cout<<a;
                  if(b<0){
                  cout<<b;
                  }
               else{
                  cout<<'+'<<b;
               }
               if(c<0){
                  cout<<c;
               }
               else{
                  cout<<'+'<<c;
               }
               if(d<0){
                  cout<<d;
               }
               else{
                  cout<<'+'<<d;
               }
                  cout<<"=7"<<endl;
                  flag=false;
               }
               
            }
         }
      }
     

}



Measured memory_bytes: 256
n,k = gets.chomp.split.map &:to_i

ans = 0
if n < k
  coin = (1..n).to_a
  ok = []
else
  coin = (1..k-1).to_a
  ok = (k..n).to_a
end

ans += ok.length / n.to_f

coin.each do |point|
  rate = 1 / n.to_f
  while(point < k)
    rate = rate / 2.to_f
    point = point * 2
  end
  ans += rate
end

p ans


Measured memory_bytes: 15136
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i < 100000; ++i) {
        if (i * 108 / 100 - i == a && i * 110 / 100 - i == b) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}

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

int main(){
	int month[13]={0,31,29,31,30,31,30,31,31,30,31,30,31},m,d,sum=0;
	string str[7]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
	while(cin>>m>>d,m+d){
		sum=0;
		for(int i=1;i<m;i++){
			sum+=month[i];
		}
	sum+=d;
	cout<<str[sum%=7]<<endl;;
	}
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
 
using 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 pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const ll MOD = 1e9 + 7;



int main() {
    int n, k;  cin >> n >> k;
    vector<int> as(n);
    rep(i, n) cin >> as[i];
    rep(i, k)  {
        vector<int> dps(n+1, 0); 
        rep(j, n) {
            int a = as[j];
            int lb = max(0, j - as[j]), mb = min(n-1, j + as[j]);
            dps[lb]++;
            dps[mb+1]--;
        }
        int aa = 0;
        rep(l, n) {
            aa += dps[l];
            as[l] = aa; 
        } 
        bool isdone = true; 
        for(int a : as) {
            if (a != n) {
                isdone = false;
                break;
            }
        }
        if (isdone) break;
    }
    for(int a : as) cout << a << " ";
    cout << endl;  
    return 0;
}

Measured memory_bytes: 4812
N,M,Q=map(int,input().split())
ABCD=[list(map(int,input().split())) for i in range(Q)]
ans=0
A=[i for i in range(1,M+1)]
#print(A)

T=[[i] for i in range(1,M+1)]
for i in range(N-1):
    newT=[]
    for j in range(len(T)):
        t=T[j]
        num=T[j][-1]
        while num<=M:
            newT.append(t+[num])
            num+=1
    T=newT
#print(T)

for x in range(len(T)):
    points=0
    #print(T[x])
    for q in range(Q):
        a=ABCD[q][0]
        b=ABCD[q][1]
        if T[x][b-1]-T[x][a-1]==ABCD[q][2]:
            points+=ABCD[q][3]
    ans=max(ans,points)

print(ans)

Measured memory_bytes: 30460
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b; 
    cout << (a-1) * (b-1);
    cout << endl;
}


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

const int maxn=1e5+5;
typedef long long ll;
const int mod=1e9+7;
int a[2005];
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    if(n<3){
        cout<<"0"<<endl;
        return 0;
    }
    a[1]=0;
    a[2]=0;
    a[3]=1;
    a[4]=1;
    a[5]=1;
    a[6]=2;
    a[7]=3;

    for(int i=8;i<=n;i++){
        a[i]=(a[i-1]+a[i-3])%mod;
    }
    cout<<a[n]<<endl;


    return 0;
}


Measured memory_bytes: 3632