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

#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,a,n) for(ll i=a;i<n;i++)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll, ll> pll;

const int INF = 100000000;
const ll LINF = 1e18+5;


ll dp[4096][1000];

int main() {
    ll N, M;
    cin >> N >> M;
    ll A[1000] = {};
    ll B[1000] = {};
    rep(i,M) {
        ll a, b;
        cin >> a >> b;
        A[i] = a;
        rep(j,b){
            ll c;
            cin >> c;
            B[i] |= (1<<(c-1));
        }
    }
    rep(i,(ll)pow(2,N)) {
        rep(j,M+1) {
            if(i==0) dp[i][j] = 0;
            else if(j==0) dp[i][j] = LINF;
            else {
                dp[i][j] = min(dp[i][j-1], dp[i & ~B[j-1]][j-1] + A[j-1]);
            }
        }
    }
    ll ans = dp[(ll)pow(2,N)-1][M];
    if(ans < LINF) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 32256
#include <stdio.h>
#include <math.h>

int main(void){
    int H, M, A, B; 
    double Hx, Hy, Mx, My, Hr, Mr, d;

    scanf("%d%d%d%d", &A, &B, &H, &M);

    Hr = (M_PI/2) - (M_PI/6)*H - (M_PI/360)*M;
    Hx = A*cos(Hr);
    Hy = A*sin(Hr);
    Mr = (M_PI/2) - (M_PI/30)*M;
    Mx = B*cos(Mr);
    My = B*sin(Mr);

    d = sqrt((Hx - Mx)*(Hx - Mx) + (Hy - My)*(Hy - My)); 
    printf("%.20f\n", d);

    return 0;
}


Measured memory_bytes: 2516
s=input()
ans=0
i=0
c=-1
tmp1=0#Sが連続した数
tmp2=0
x=0
y=0
while i<len(s):
    if c==-1:
        if s[i]=="S":
            tmp1=1
            c=0
        else:
            tmp2+=1
            c=1
    elif c==0:
        if s[i]=="S":
            tmp1+=1
        else:
            tmp2+=1
            c=1
    elif c==1:
        if s[i]=="S":
            if tmp1>=tmp2:
                tmp1=tmp1-tmp2
                tmp2=0
            else:
                y+=tmp2-tmp1
                tmp2=0
                tmp1=0
            c=0
            tmp1+=1
        else:
            tmp2+=1
    if i==len(s)-1:
        if tmp1>=tmp2:
            x+=tmp1-tmp2
            tmp2=0
        else:
            y+=tmp2-tmp1
            tmp1=0
    i+=1
    
    #print(ans,tmp1,tmp2,x,y)
print(x+y)

Measured memory_bytes: 9332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mxn = (int)2e5 + 5;

ll nCr(ll n){
    return (n * (n - 1) / 2);
}
map <ll, ll> cnt;

int main () {
	
	ll n;
	cin >> n;
	
	ll a[n+3];
	set <ll> Set;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		Set.insert(a[i]);
		cnt[a[i]]++;
	}
	
	vector <ll> v(Set.begin(), Set.end());

	ll dp[n+3];
	ll res = 0;
	memset(dp, -1LL, sizeof dp);
	
	for (int i = 0; i < (int) v.size(); ++i) {
		if (dp[i] == -1) {
			dp[i] = nCr(cnt[v[i]]);
		}
		res += dp[i];
	}
	
	for (int i = 0; i < n; ++i) {
		cout << res - cnt[a[i]] + 1 << endl;
	}
	
	return 0;
}


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

int main(){
	int a, b;
	char op;
	while (1){
		cin >> a >> op >> b;
		if (op == '?') break;
		switch (op){
		case '+':
			cout << a + b << endl;
			break;
		case '-':
			cout << a - b << endl;
			break;
		case '*':
			cout << a * b << endl;
			break;
		case '/':
			cout << a / b << endl;
			break;
		default:
			break;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	long long X;
	cin >> X;
	long long money = 100;
	int N = 0;
	while (money < X) {
		money = money + money / 100;
		N++;
	}
	cout << N << endl;
}

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

using namespace std;

int main(){
string S; cin >> S; int N = (int) S.size();
  vector<int> children(N,0);
  
  vector<int> vec;
  
  for(int i = 0; i < N - 1 ; i++){
    if( S[i] == 'R' && S[i+1] == 'L'){
      // Rのイテレータを収納
      vec.push_back(i);}}
  
  for(int j = 0; j < N; j++){
    //それぞれの子供がどこへ行くのか考える
    if( S[j] == 'R'){
      //右側の RL　ループへとぶ
      int c = lower_bound( vec.begin(),vec.end(), j) - vec.begin();
      int k = vec[c] - j; 
      if( k % 2 ){ // S[i] == R　から、最寄りのRLのRまでの距離が奇数だった時、Lまで行く
        children[vec[c]+1]++;} 
      else{ children[vec[c]]++;}}
    
    else if( S[j] == 'L'){
      int c = lower_bound( vec.begin(),vec.end(), j) - vec.begin();
      c--;
      int k = j -  vec[c]; 
      if( k % 2){ //kが奇数の時、Lで終わる
        children[vec[c] + 1]++;}
      else{ children[vec[c]]++;} }
    }
    
    for(int i = 0; i < N; i++){
      cout << children[i] << " ";}
    
    cout << endl; return 0;}
      

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int a[3][3];
  int b[3][3];
  
  for(int y=0; y<3; y++) 
    for(int x=0; x<3; x++) {
      cin >> a[y][x];
      b[y][x] = a[y][x];
    }
  
  // 行2と行０、行1と行0の差分を比較する。
  a[1][0] = a[1][0] -a[0][0];
  a[1][1] = a[1][1] -a[0][1];
  a[1][2] = a[1][2] -a[0][2];
  
  a[2][0] = a[2][0] -a[0][0];
  a[2][1] = a[2][1] -a[0][1];
  a[2][2] = a[2][2] -a[0][2];
                          
  bool a1 = ( a[1][0] == a[1][1] && a[1][1] == a[1][2] );
  bool a2 = ( a[2][0] == a[2][1] && a[2][1] == a[2][2] );
  
  // 列2と列０、列1と列0の差分を比較する。
  b[0][1] = b[0][1] -b[0][0];
  b[1][1] = b[1][1] -b[1][0];
  b[2][1] = b[2][1] -b[2][0];
  
  b[0][2] = b[0][2] -b[0][0];
  b[1][2] = b[1][2] -b[1][0];
  b[2][2] = b[2][2] -b[2][0];
                          
  bool b1 = ( b[0][1] == b[1][1] && b[1][1] == b[2][1] );
  bool b2 = ( b[0][2] == b[1][2] && b[1][2] == b[2][2] );
  
  if (a1 && a2 && b1 && b2 ) cout << "Yes" << endl;
  else						cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		for(;;){
			int N=cin.nextInt();
			if(N==0)break;
			int a[] = new int[10];
			for(int i = 0;i<N;i++){
				a[cin.nextInt()]++;
			}
			for(int i = 0;i<10;i++){
				for(int j = 0;j<a[i];j++){
					System.out.print("*");
				}
				if(a[i]==0){
					System.out.print("-");
				}
				System.out.println();
			}
		}

	}

}

Measured memory_bytes: 12000
/**
*    author:  yuya1234
*    created: 09.07.2020 13:49:17
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define ALL(v) (s).begin(), (s).end()
#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  string s,t;
  cin>>n>>s>>t;

  int ans=SZ(s)+SZ(t);
  bool flg=false;

  REP(i,SZ(s))
  {
    for(int j=0;j<min(SZ(s)-(int)i,SZ(t));j++)
    {
      if(s[i+j]==t[j])flg=true;
      else
      {
        flg=false;
        break;
      }
    }
    if(flg && max(SZ(t),SZ(s))+i>=n)
    {
      ans=max(SZ(t),SZ(s))+i;
      break;
    }
  }

  cout<<ans<<endl;

  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    int res = 0;
    rep(i, 0, s.size()){
        if(s[i] == 'I') ans++;
        else ans--;
        res = max(res, ans);
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 3524
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#define show(...) cerr << #__VA_ARGS__ << " = ",debug(__VA_ARGS__);
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T, typename S>
ostream &operator<<(ostream &os,pair<T,S>a){
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, vector<T> v){
    for(auto x:v)os << x << ' ';
    return os;
}
void debug(){cerr << '\n';}
template<typename H, typename... T>
void debug(H a, T... b){
    cerr << a;
    if(sizeof...(b))cerr << ", ";
    debug(b...);
}
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};
signed main(){
    int n,m;
    cin >> n >> m;
    vector<ll>ans(m);
    vector<pii>e;
    UnionFind uf(n);
    rep(i,m){
        int c,d;
        cin >> c >> d;
        c--,d--;
        e.emplace_back(c,d);
    }
    reverse(e.begin(), e.end());
    ll t = (ll)n*(n-1)/2;
    rep(i,m){
        ans[i] = t;
//        show(t);
        if(uf.same(e[i].first,e[i].second))continue;
        else{
            ll k = uf.size(e[i].first);
            ll kk = uf.size(e[i].second);
            uf.unite(e[i].first,e[i].second);
            t -= k*kk;
        }
    }
    assert(t==0);
    reverse(ans.begin(),ans.end());
    rep(i,m)cout << ans[i] << "\n";
}


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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define rf(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rb(i,b,a) for(int (i) = (b); (i) >= (a); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl
#define test(t) int(testCnt) = 0; int(t); cin >> (t); while(t -- && ++testCnt)

const int INF = 2e9 + 7;
const int MAXA = 3e3 + 10;
const ll MOD = (ll) 1e9 + 7;
const ll INFLL = 9e18 + 7;

typedef pair<int, int> ii;
typedef pair<ii, int> II;
typedef vector<int> vi;
typedef vector<ii> vii;

int n;
double ans, f[MAXA][MAXA], p[MAXA];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
     //   freopen("in.in", "r", stdin);
    #endif
    cin >> n;
    rf(i, 1, n) cin >> p[i];
    f[1][0] = 1 - p[1];
    f[1][1] = p[1];
    rf(i,2,n) {
        rf(j,0,i) {
            if(i - 1 >= j)
                f[i][j] += f[i - 1][j] * (1 - p[i]);
            f[i][j] += f[i - 1][j - 1] * p[i];
        }
    }
    rf(i, n / 2 + 1, n) ans += f[n][i];
    cout << setprecision(10) << ans;
    return 0;
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


int dp[123456];


signed main() {

	int N, M;
	cin >> N >> M;
	int a[123456];
	rep(i, M) cin >> a[i];

	dp[0] = 1;
	for (int i = 1; i <= N; i++) {
		if (i >= 2) {
			bool i1 = binary_search(a, a + M, i - 1);
			bool i2 = binary_search(a, a + M, i - 2);
			if (i1 && i2) { cout << 0 << endl; return 0; }
			if(i1)
				dp[i] = dp[i - 2];
			else if(i2)
				dp[i] = dp[i - 1];
			else
				dp[i] = dp[i - 1] + dp[i - 2];
			dp[i] %= mod;
		}
		else {
			bool i1 = binary_search(a, a + M, i - 1);
			if (i1) { cout << 0 << endl; return 0; }
			dp[i] = dp[i - 1];
		}
	}
	cout << dp[N] % mod << endl;

	return 0;
}


Measured memory_bytes: 1408
#include<iostream>

int main() {
  long int n, n2;
  std::cin >> n;
  n2 = n/2;
  if (n2 == 0) {
    n2 = 1;
  }
  for (long int i=n2; i > 0; i--) {
    if (i*i <= n) {
      std::cout << i*i;
      break;
    }
  }
  return 0;
}


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

void selection_sort(vector<int>& vec, const int n) {
  int cnt = 0;
  bool flg = false;
  for(int i = 0; i < n; i++) {
    int minj = i;
    for(int j = i; j < n; j++) {
      if(vec[j] < vec[minj]) {
        minj = j;
        flg = true;
      }
    }
    swap(vec[i], vec[minj]);
    if(flg) { cnt++; flg = false; }
  }

  for(int i = 0; i < n; i++) {
    cout << vec[i];
    if(i != n -1) { cout << " "; }
    else { cout << endl; }
  }
  cout << cnt << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for(auto& v : vec) {
    cin >> v;
  }
  selection_sort(vec, n);
  return 0;
}



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

bool check(char c,string s)
{
    for(int i=0;i<s.size();++i)
        if(s[i]==c)
            return true;
    return false;
}
int main()
{
    string str;
    cin>>str;
    bool flag=true;
    for(int i=0;i<str.size();++i)
    {
        if(i%2==0)  flag&=check(str[i],"RUD");
        else flag&=check(str[i],"LUD");
    }
    if(flag)    cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
n,m,q = map(int, input().split())
cons = []
for _ in range(q):
  con = list(map(int, input().split()))
  cons.append(con)

def next(an):
  for i in range(n)[::-1]:
    if an[i]==m:
      an[i]=0
    else:
      an[i] += 1
      break
  for i in range(n-1):
    if an[i+1]==0:
      an[i+1] = an[i]
  return an

an = [1] * n
max_score = 0

while True:
  score = 0
  if an[0]==0:
    break
  for i in range(q):
    a,b,c,d = cons[i]
    if an[b-1] - an[a-1] == c:
      score += d
  if score > max_score:
    max_score = score
  an = next(an)

print(max_score)



Measured memory_bytes: 9236
#include <iostream>

 

using namespace std;

 

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if(x-r>=0 && y-r>=0 && x+r<=w && y+r<=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3108
N = int(input())
lst = []
chair = []
res = 0
lst = input().split()
for i in range(N):
    lst[i] = int(lst[i])
for index in range(1,N):
    if lst[index] < lst[index-1]:
        chair.append(lst[index-1]-lst[index])
        lst[index] = lst[index-1]
for i in chair:
    res += i
print(res)

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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; ++i) cin >> L[i];

    long long ans = 0;
    sort(L.begin(), L.end());

    for (int i = 0; i < N-2; ++i) {
        for (int j = i+1; j < N-1; ++j) {
            auto itr = lower_bound(L.begin() + j + 1, L.end(), L[i] + L[j]);
            ans += itr - (L.begin() + j + 1);
        }
    }
    cout << ans << endl;
}

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

int main(){
  string a;
  cin >> a;
  if(a == "ABC"){
    cout << "ARC" << endl;
  }
  else if(a == "ARC"){
    cout << "ABC" << endl;
  }
  else{
    cout << "error" << endl;
  }
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            input_iter = LazyLoadAllLines();
            //------------------------------------------------//
            //var h = Read<long>();
            //var n = Read<long>();
            //var m = Read<long>();
            //var s = Read();
            //var cls = Read<long>(n);
            //var bls = Read<long>(n);
            //var sls = Read(n);
            /*List<(string s, long c)> scls = new List<(string s, long c)>();
            for (int i = 0; i < m; ++i)
            {
                scls.Add((Read(), Read<long>()));
            }*/
            //List<List<long>> abls = new List<List<long>>();
            //List<long> cls = new List<long>();
            /*List<long> edgeNum = Enumerable.Repeat(0L, (int)n).ToList();
            for (int i = 0; i < n - 1; ++i)
            {
                abls.Add(Read<long>(2));
                abls[i].Add(i);
                abls[i].Add(-1);
                --abls[i][0];
                --abls[i][1];
                //cls.Add(Read<long>());
                ++edgeNum[(int)abls[i][0]];
                ++edgeNum[(int)abls[i][1]];
            }*/
 
            //als.Sort((l, r) => (int)(r - l));
 
            var s = Read();
            var t = Read();
            var a = Read<long>();
            var b = Read<long>();
            var u = Read();
 
            Console.WriteLine(s == u ? $"{a - 1} {b}" : $"{a} {b - 1}");
        }
 
        static IEnumerator<string> input_iter;
 
        static IEnumerator<string> LazyLoadAllLines(bool doSplit = true)
        {
            string line;
            if (doSplit)
            {
                do
                {
                    line = Console.ReadLine();
                    foreach (var s in line.Split(' '))
                        yield return s;
                } while (line != null);
            }
            else
            {
                do
                {
                    line = Console.ReadLine();
                    yield return line;
                } while (line != null);
            }
        }
        static _T Read<_T>() where _T : struct
        {
            input_iter.MoveNext();
            return (_T)Convert.ChangeType(input_iter.Current, typeof(_T));
        }
        static string Read()
        {
            input_iter.MoveNext();
            return input_iter.Current;
        }
        static List<_T> Read<_T>(long num) where _T : struct
        {
            List<_T> res = new List<_T>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add((_T)Convert.ChangeType(input_iter.Current, typeof(_T)));
            }
            return res;
        }
        static List<string> Read(long num)
        {
            List<string> res = new List<string>();
            for (long i = 0; i < num; ++i)
            {
                input_iter.MoveNext();
                res.Add(input_iter.Current);
            }
            return res;
        }
 
    }
}

Measured memory_bytes: 13140
def ok
  N.times do |i|
    N.times do |j|
      next unless 0<=i && i+M-1<N
      f=true
      M.times do |k|
        M.times do |l|
          f=false if A[i+k][j+l]!=B[k][l]
        end
      end
      return true if f
    end
  end
  false
end
N,M=gets.split.map &:to_i
A=N.times.map{gets.chop}
B=M.times.map{gets.chop}
puts ok ? :Yes : :No


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

int main() {
  int k,n;
  cin >> k >> n;
  vector<int> a(n);
  rep(i,n) {
    cin >> a.at(i);
  };
  a.push_back(a.at(0) + k);
  int l = 0;
  rep(i,n) {
    l = max(l,a.at(i + 1) - a.at(i));
  };
  int ans = k - l;
  cout << ans;
};

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define int long long
signed main(){
    ll n;
    cin >> n;
    vector<int> v;
    vector<int> p;
    int s = 100;
    while(n!=0){
        if(v.size()==0){
            v.push_back(1);
            p.push_back(s);
            s--;
            n-=1;
            continue;
        }   
        int c = 1;
        int k = 0; 
        for(int i=v.size()-1;i>=0;i--){
            if(c+v[i]<=n){
                c += v[i];
            }else{
                k = i+1;
                break;
            }
        }
        vector<int> a;
        vector<int> b;
        rep(i,v.size()){
            if(i==k){
                b.push_back(s);
                s--;
                a.push_back(c);
            }
            a.push_back(v[i]);
            b.push_back(p[i]);
        }
        if(k==v.size()){
            a.push_back(c);
            b.push_back(s);
            s--;
        }
        v = a;
        p = b;
        n -= c;
    }
    cout << 100 + v.size() << endl;
    rep(i,100){
        cout << i+1 << " ";
    }
    rep(i,p.size()){
        cout << p[i];
        if(i!=p.size()-1){
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <fstream>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define EPS 1e-9
#define INF MOD
#define MOD 1000000007LL
#define fir first
#define iss istringstream
#define sst stringstream
#define ite iterator
#define ll long long
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define pi pair<int,int>
#define pb push_back
#define sec second
#define sh(i) (1LL<<i)
#define sz size()
#define vi vector<int>
#define vc vector
#define vl vector<ll>
#define vs vector<string>

int N,T,M[1010],L[1010],K[1010],a[1010];

int main(){
	while(cin>>N>>T&&N){
		rep(i,N)cin>>M[i]>>L[i]>>K[i];
		rep2(P,1,N+1){
			fill(a,a+N,0);
			int t=0,d=0;
			multiset<int> S;
			rep(i,P)S.insert(0);
			int e=0;
			while(d<N&&t<=T&&e<=T){
				int nx=-1;
				rep(i,N)if(!a[i]&&t%(L[i]+K[i])<=L[i]){nx=i;break;}
				if(nx>-1&&*S.begin()<=t)a[nx]=1,d++,e=max(e,t+M[nx]),S.erase(S.begin()),S.insert(t+M[nx]);
				else{t++;continue;}
			}
			if(d==N&&e<=T){cout<<P<<endl;break;}
		}
	}
}

Measured memory_bytes: 948
#include <bits/stdc++.h>
#define debug(a) cout << #a ": " << a << endl
#define IOS ios::sync_with_stdio(false), cin.tie(0)
using namespace std;
typedef long long ll;

int main(void){
    IOS;
    int x; cin >> x;
    int y = 360;
    int g = __gcd(x, y);
    x /= g, y /= g;
    cout << y << endl;
    return 0;
}
 

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A <= 5) {
    cout << 0 << endl;
  } else if (A <= 12) {
    cout << B / 2 << endl;
  } else {
    cout << B << endl;
  }
  return 0;
}



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

using namespace std;

typedef long long ll;

int getClockDist(int from, int to, int k) {
	if (to < from) to += k;
	return to - from;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int k, n;
	cin >> k >> n;
	
	int houses[n];
	for (int i = 0; i < n; i++) {
		cin >> houses[i];
	}
	
	sort(houses, houses + n);
	int minTot = k;
	for (int startId = 0; startId < n; startId++) {
		int lastId = startId == 0 ? n - 1 : startId - 1;
		int dist = getClockDist(houses[startId], houses[lastId], k);
		minTot = min(minTot, dist);
	}
	
	cout << minTot << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>
#include <chrono>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = 1e5 + 1;
const int mod = 1e9 + 7;

int f[MAXN];

int powmod(int a, int p) {
    if (p == 0) return 1;
    if (p == 1) return a;
    int k = powmod(a, p / 2);
    if (p & 1) return (((k * k) % mod) * a) % mod;
    return (k * k) % mod;
}

int rev(int k) {
    return powmod(k, mod - 2);
}

int C(int n, int k) {
    int ans = f[n];
    ans = (ans * rev(f[k])) % mod;
    ans = (ans * ref(f[n - k])) % mod;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    f[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        f[i] = (f[i - 1] * i) % mod;
    }
    int n, k;
    cin >> n >> k;
    int dp[MAXN];
    dp[k] = 1;
    int ans = k;
    for (int i = k - 1; i >= 1; i--) {
        dp[i] = powmod(k / i, n);
        for (int j = i + i; j <= k; j += i) {
            dp[i] -= dp[j];
            if (dp[i] < 0) dp[i] += mod;
        }
        ans += (dp[i] * i) % mod;
        ans %= mod;
//        cout << i << " " << dp[i] << "\n";
    }
    cout << ans;
    //----------------------------------------------------------------------
//    #ifdef LOCAL
//        cout << "\n";
//        cerr << "Time elapsed: " << (double)clock()/CLOCKS_PER_SEC << "s.\n";
//    #endif
}
/*

*/


Measured memory_bytes: 4728
#include <algorithm>
#include <iostream>
#include <vector>
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; }

const int MOD = (int)1e9 + 7;
struct mint { int n; mint(int n = 0) : n(n) { } };
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }

int main() {
    int H, W; cin >> H >> W;
    vector<string> a(H);
    for (int i = 0; i < H; i++) cin >> a[i];

    vector<vector<mint>> dp(H, vector<mint>(W, 0));
    dp[0][0] = 1;
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) {
        if (a[i][j] == '.') {
            if (i - 1 >= 0) dp[i][j] += dp[i - 1][j];
            if (j - 1 >= 0) dp[i][j] += dp[i][j - 1];
        }
    }
    cout << dp[H - 1][W - 1] << endl;
    return 0;
}

Measured memory_bytes: 5248
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <cinttypes>
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

struct edge
{
    // 頂点 最短時間
    int a;
    int64_t cost;

    edge() {};
    edge(int a, int64_t cost)
        : a(a), cost(cost) {}

    bool operator> (const edge &edge) const
    {
        return cost > edge.cost;
    }
};

// 始点 頂点0
int start = 0;

// 道情報 行き 配列
vector< vector<edge> > goList;

// 所要時間 行き 配列
vector<int64_t> goAry;

// 行ったことある、ない
vector<bool> gone;

void bfs()
{
    queue<edge> que;

    // スタート地点をキューに入れる
    que.push(edge(start, 0));

    // 距離を0にする
    goAry[start] = 0;

    // 行ったことがある
    gone[start] = true;

    while (que.size())
    {
        edge q = que.front();
        que.pop();

        for (int i = 0; i < (signed)goList[q.a].size(); i++)
        {
            edge e = goList[q.a][i];

            // 行ったことがない
            if (gone[e.a] == false)
            {
                goAry[e.a] = goAry[q.a] + e.cost;
                // push 頂点 時間
                que.push(edge(e.a, goAry[e.a]));
                // 行ったことがある
                gone[e.a] = true;
            }
        }
    }
}

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    goList.resize(N);

    for (int i = 0; i < N - 1; i++)
    {
        int a, b;
        int64_t c;
        if (scanf("%d%d%" PRId64, &a, &b, &c) < 3) return 0;

        // 0-indexed
        a--;
        b--;

        goList[a].push_back(edge(b, c));
        goList[b].push_back(edge(a, c));
    }

    goAry.resize(N);
    gone.resize(N);

    for (int i = 0; i < N - 1; i++)
    {
        // 初期化
        goAry[i] = 0;
        // 行ったことがない
        gone[i] = false;
    }

    int Q;
    int K;
    if (scanf("%d%d", &Q, &K) < 2) return 0;

    start = --K;

    // 幅優先探索 Breadth-First Search
    bfs();

    int x;
    int y;
    for (int i = 0; i < Q; i++)
    {
        if (scanf("%d%d", &x, &y) < 2) return 0;
        x--;
        y--;
        printf("%" PRId64 "\n", goAry[x] + goAry[y]);
    }

    return 0;
}


Measured memory_bytes: 10736
// ------------------------------------
// Date:2018/ 3/13
// Problem:ABC 069 i18n b.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  string s;
  cin >> s;
  cout << s[0];
  cout << s.size() - 2;
  cout << s[s.size() - 1] << endl;
  return 0;
}



Measured memory_bytes: 256
/*
Saurabh Joshi
IIIT Jabalpur
*/
#include<bits/stdc++.h>
#define LL long long int
#define M 1000000007
#define endl "\n"
#define eps 0.00000001
LL pow(LL a,LL b,LL m){LL x=1,y=a;while(b > 0){if(b%2 == 1){x=(x*y);if(x>m) x%=m;}y = (y*y);if(y>m) y%=m;b /= 2;}return x%m;}
LL gcd(LL a,LL b){if(b==0) return a; else return gcd(b,a%b);}
LL gen(LL start,LL end){LL diff = end-start;LL temp = rand()%start;return temp+diff;}
using namespace std;
LL d[1000001];
LL m[1000001];
LL c[1000001];
LL p[1000001];
int main()
    {
        ios_base::sync_with_stdio(0);
        int n;
        cin >> n;
        string s;
        cin >> s;
        s = " " + s;
        for(int i = 1; i < s.length(); i++) {
            d[i] = d[i - 1];
            m[i] = m[i - 1];
            c[i] = c[i - 1];
            if(s[i] == 'D') {
                ++d[i];
            }
            else if(s[i] == 'M')    {
                ++m[i];
            }
            else if(s[i] == 'C')    {
                ++c[i];
            }
        }
        for(int i = 1; i <= n; i++){
            if(s[i] == 'M') {
                p[i] = c[n] - c[i];
            }
            else{
                p[i] = 0;
            }
        }
        for(int i = 1; i <= n; i++) {
            p[i] += p[i - 1];
        }
        int q;
        cin >> q;
        while(q--)  {
            int k;
            LL ans = 0;
            cin >> k;
            for(int i = 1; i <= n; i++) {
                if(s[i] == 'D') {
                    int R = min(n , i + k - 1);
                    
                    ans = ans + p[R] - p[i];
                    ans = ans - (m[R] - m[i]) * (c[n] - c[R]); 
                }
            }
            cout << ans << endl;

        }
    }

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

int main(){
  int n;
  string s, t, m;
  cin >> n >> s >> t;

  for(int i = 0; i<s.size() * 2; i++){
    if(i%2 == 0)
      m += s.at(i/2);
    else
      m += t.at(i/2);
  }
  cout << m << endl;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;

constexpr size_t    operator""_sz(unsigned long long value) { return value; };
constexpr intmax_t  operator""_im(unsigned long long value) { return value; };
constexpr uintmax_t operator""_um(unsigned long long value) { return value; };
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t N, M;
    cin >> N >> M;

    vector<intmax_t> d(N), c(M);
    for (auto &di: d) cin >> di;
    for (auto &ci: c) cin >> ci;


    auto dp = make_v(LINF, N + 1, M + 1);
    dp[0][0] = 0;
    for (size_t city = 0; city < N; ++city) {
        for (size_t day = 0; day < M; ++day) {
            chmin(dp[city + 1][day + 1], dp[city][day] + d[city] * c[day]);
            chmin(dp[city][day + 1], dp[city][day]);
        }
    }

    intmax_t res = LINF;
    for (size_t day = 1; day <= M; ++day) {
        chmin(res, dp[N][day]);
    }

    cout << res << "\n";

    return 0;
}



Measured memory_bytes: 9132
// ABC061B - 

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

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int N, M;
	cin >> N >> M;

	int a[M], b[M];
	map<int, int> p;
	for (int i = 0; i < M; i++) {
		cin >> a[i] >> b[i];
		p[a[i]]++;
		p[b[i]]++;
	}

	for (int i = 1; i <= N; i++) {
		cout << p[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
fun main() {
    println(10.minus(nextInt().div(200)))
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

Measured memory_bytes: 34544
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e4;

char arr[N][N];
char arr1[N][N];
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0; i<n; i++)
        scanf("%s",arr[i]);
 
    for(int i=0; i<m; i++)
        scanf("%s",arr1[i]);
 
 
    for(int i=0; i<n; i++)
    {
        for(int j=0; j<n; j++)
        {
            int cnt=0;
            for(int a=0; a<m; a++)
            {
                for(int b=0; b<m; b++)
                {
                    if(arr1[a][b]==arr[i+a][j+b])
                        cnt++;
                }
 
            }
            if(cnt==(m*m))
            {
                printf("Yes\n");
                return 0;
            }
 
        }
    }
    printf("No\n");
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int x;
    cin>>x;
    int flag=0;
    for (long long int i=-500;i<=500;i++) {
        for (long long int j=-500;j<=500;j++) {
            if (pow(i,5)-pow(j,5)==x) {
                cout<<i<<" "<<j<<endl;
                flag=1;
                break;
            }
        }
        if (flag==1) {
            break;
        }
    }
}

Measured memory_bytes: 4060
def main():
    # input
    n = int(input())

    # calc
    ans = 10**13
    for i in range(1, int(n**0.5)+1):
        num = n / i
        if num - int(num) == 0:
            ans = min(ans, i+num-2)
    print(int(ans))

# if __name__ == '__main__':
main()


Measured memory_bytes: 39280
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

const double pi = acos(-1);

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

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

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

    double r; cin>>r;

    cout << pi * 2 * r << endl;

    return 0;
}

Measured memory_bytes: 3808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int[][] a = new int[9][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                a[i][j] = (i + 1) * (j + 1);
            }
        }
        int x = in.nextInt();
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                if (x == a[i][j]) {
                    out.println("Yes");
                    return;
                }
            }
        }
        out.println("No");
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


Measured memory_bytes: 23636
/*program by mangoyang*/
#include<bits/stdc++.h>
#define inf (0x7f7f7f7f)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
typedef long long ll;
using namespace std;
template <class T>
inline void read(T &x){
    int f = 0, ch = 0; x = 0;
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') f = 1;
    for(; isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
    if(f) x = -x;
}
#define int ll
char s[1000005];
int buf[100], n, ans;
main(){
	scanf("%s", s); n = strlen(s);
	for(int i = 0; i < n; i++){
		int c = s[i] - 'a';
		ans += i - buf[c]; buf[c]++;
	} 
	cout << ans + 1;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n;
    cin >> n;
    ll ans = 0;
    for (int a = 1; a < n; a++) {
        ans += (n - 1) / a;
    }
    cout << ans << endl;
    return 0;
}

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


using namespace std;
typedef long long ll;

ll gcd(ll a, ll b){
    ll r;
    while((r =a%b)){
        a = b;
        b = r;
    }
    return b;
}

int main(){
    ll A,B,C,D,ans;
    cin>>A>>B>>C>>D;

    ll numc = 0, numd = 0, numgcd = 0;

    numgcd = gcd(C,D);

    /*if(B%C == 0){
        numc = B/C - A/C+1;
        
    }else{
        numc = B/C - A/C;
        
    }
    if(B%D == 0){
        
        numd = B/D - A/D+1;
    }else{
        
        numd = B/D - A/D;
    }*/
    ll aaa = (C*D)/numgcd;
    numc = B/C - (A-1)/C;
    numd = B/D - (A-1)/D;
    ll numnew = B/aaa -(A-1)/aaa;

    

    ans = B-A+1 -(numc+numd-numnew);
    
    cout << ans <<endl;

    return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<char, char> pcc;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pcc C[200005];
string S;
ll N, Q;
bool checkL(ll n)
{
    REP(i, Q)
    {
        if (C[i].first == S[n])
        {
            if (C[i].second == 'L')
                n--;
            else
                n = std::min(n + 1, N - 1LL);
            if (n < 0)
                return true;
        }
    }
    return false;
}
bool checkR(ll n)
{
    REP(i, Q)
    {
        if (C[i].first == S[n])
        {
            if (C[i].second == 'L')
                n = std::max(0LL, n - 1);
            else
                n++;
            if (n > N - 1)
                return true;
        }
    }
    return false;
}

int main()
{
    cin >> N >> Q;
    cin >> S;
    REP(i, Q)
    {
        cin >> C[i].first >> C[i].second;
    }

    ll left = 0;
    {
        //! 左に落ちる最大値
        ll ok = 0, ng = N;
        while (abs(ok - ng) > 1)
        {
            ll mid = (ok + ng) / 2;
            if (checkL(mid))
                ok = mid;
            else
                ng = mid;
        }
        if (ok == 0)
        {
            bool c = false;
            REP(i, Q)
            {
                if (S[ok] == C[i].first)
                {
           

                    if (C[i].second == 'L')
                    {
                        ok--;
                    }
                    else
                    {
                        ok = std::min(ok + 1, N - 1);
                    }

                    if (ok < 0)
                    {
                        c = true;
                        break;
                    }
                }
            }
            if (!c)
                ok = -1;
            else
                ok = 0;
        }
        left = ok + 1;

    }
    ll right = 0;
    {
        //! 左に落ちる最大値
        ll ok = N - 1, ng = -1;
        while (abs(ok - ng) > 1)
        {
            ll mid = (ok + ng) / 2;
            if (checkR(mid))
                ok = mid;
            else
                ng = mid;
        }
        if (ok == N - 1)
        {
            bool c = false;
            REP(i, Q)
            {
                if (S[ok] == C[i].first)
                {
                    if (C[i].second == 'L')
                        ok = std::max(0LL, ok - 1);
                    else
                        ok++;
                    if (ok > N - 1)
                    {
                        c = true;
                        break;
                    }
                }
            }
            if (!c)
                ok = N;
            else
                ok = N - 1;
        }
        right = N - ok;
    }
    cout << N - std::min(N, left + right) << endl;
    return 0;
}

Measured memory_bytes: 900
#include <stdio.h>
int binary_search(int *s,int key,int n){
  int l,r;
  int m;
  l=0;
  r=n-1;
  while(l<=r){
    m=(l+r)/2;
    if(key==s[m]) return 1; 
    if(key<s[m])r=m-1;
    else l=m+1;
  }
    return 0;
}
int main(){
  int i,j;
  int n=15;
  int s[100000];
  int q;
  int count=0;
  int t;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&t);
    count=count+binary_search(s,t,n);
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 988
N = int(input())

L = [list(map(int, input().split())) for _ in range(N)]

L.sort(key=lambda x:x[1])

now = 0
flag = False
for l in L:
    now += l[0]
    
    if now  > l[1]:
        flag = True
        break


if flag:
    print('No')

else:
    print('Yes')



Measured memory_bytes: 53600
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;

int main() {
  //
  int L, R, d;
  cin >> L >> R >> d;
  int ans = 0;
  for (int i = L; i <= R; i++) ans += (i % d == 0);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
struct edge { int to, cost; };
typedef pair<int, int>P;
#define PI 3.14159265359
#define MOD 1000000007
const int MAX =510000;

int main(){
	ll N;
  	cin >>N;
  	ll ans=0;
  	ans=(N*(N-1))/2;
  	cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String s = scanner.next();
    int cnt = 0;
    char[] reg = { 'A', 'G', 'C', 'T' };
    ArrayList<Integer> ans = new ArrayList<Integer>();
    for (int i = 0; i < s.length(); i++) {
      boolean iscont = false;
      for (int j = 0; j < 4; j++) {
        if (s.charAt(i) == reg[j]) {
          cnt++;
          iscont = true;
          break;
        }
      }
      if (!iscont) {
        ans.add(cnt);
        cnt = 0;
      }
    }
    ans.add(cnt);
    int max = ans.get(0);
    for (int i = 1; i < ans.size(); i++) {
      if (max < ans.get(i)) {
        max = ans.get(i);
      }
    }
    System.out.println(max);
  }

}


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

int n, a[100005];

signed main(){
  
  cin>>n;

  for(int i=0;i<n;i++) cin>>a[i];
  
  sort( a, a + n );

  int l = 0, r = n-1;
  
  double val = a[n-1] / 2.0;
  
  while( l < r ){
    
    int m = ( l + r ) / 2;
    
    if( a[m] < val ) l = m + 1;
    else r = m;
    
  }
  
  int minv = 0;
  
  if( 0 <= l - 1 && l - 1 < n - 1 ){
    
    if( minv < min( a[l-1], a[n-1] - a[l-1] ) ){
      minv = a[l-1];
    }
    
  }

  if( 0 <= l && l < n - 1 ){
    
    if( minv < min( a[l], a[n-1] - a[l] ) ){
      minv = a[l];
    }
    
  }

  cout<<a[n-1]<<" "<<minv<<endl;
  
  return 0;
}


Measured memory_bytes: 1024