akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn calc(v: [i32; 4], opi: u8) -> (i32, String) {
    let mut n = v[0];
    let mut exp = v[0].to_string();
    for i in 0..3 {
        if ((opi >> i) & 1) == 1 {
            exp = format!("{}+{}", exp, v[i + 1]);
            n = n + v[i + 1]
        } else {
            exp = format!("{}-{}", exp, v[i + 1]);
            n = n - v[i + 1]
        }
    }
    return (n, exp);
}

fn main() {
    input! {
        s: chars
    }
    let a = s[0] as i32 - '0' as i32;
    let b = s[1] as i32 - '0' as i32;
    let c = s[2] as i32 - '0' as i32;
    let d = s[3] as i32 - '0' as i32;

    for opi in 0..8 {
        let c = calc([a, b, c, d], opi);
        if c.0 == 7 {
            print!("{}=7",  c.1);
            break;
        }
    }
}


Measured memory_bytes: 4352
#define M 51000
n[M];main(i,j){n[0]=n[1]=1;for(i=2;i<M;i++)if(!n[i])for(j=i*2;j<M;j+=i)n[j]=1;for(;~scanf("%d",&i);printf("%d %d\n",i,j)){for(j=i+1,i--;n[i];i--);for(;n[j];j++);}exit(0);}

Measured memory_bytes: 792
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r * g * b
for j in range(1, N - 1):
    for v in range(1, min(j+1, N - j)):
        if S[j - v] != S[j] and S[j + v] != S[j] and S[j - v] != S[j + v]:
            ans -= 1

print(ans)

Measured memory_bytes: 9204
#include <stdio.h>

int main(void)
{
  int x,y;
  int a[10] = {1,3,5,7,8,10,12};
  int b[10] = {4,6,9,11};
  int c = 2;
  int i = 0;
  char X,Y;

  scanf("%d %d",&x,&y);

  for(i = 0;i < 7;i++)
    {
      if(x == a[i])
        X = 'A';
      if(y == a[i])
        Y = 'A';
    }

  for(i = 0;i < 4;i++)
    {
      if(y == b[i])
        Y = 'B';
      if(x == b[i])
        X = 'B';
    }

  if(x == c)
    X = 'C';
  if(y == c)
    Y = 'C';
  if(X==Y)
    printf("Yes\n");
  else
    printf("No\n");

  return 0;
}


Measured memory_bytes: 128
def solve(N, As):
    def f(n):
        c = 0
        while n % 2 == 0:
            c += 1
            n //= 2
        return c
    return sum([f(a) for a in As])


if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 4148
#include<bits/stdc++.h>
const int maxn=8e2+10;
using namespace std;
char a[maxn][maxn];
int stmp[maxn][maxn];//代表这是bfs的第几步
int direction[4][2]={1,0,-1,0,0,1,0,-1};//四个方向
int n,m,k;
int ans=99999999;
bool check(int x,int y)//判断这个点是否可行
{
    if(x>=0&&x<n&&y>=0&&y<m&&stmp[x][y]==0&&a[x][y]=='.')
    {
       return 1;
    }
    return 0;
}
queue<pair<int,int> >po;
int main()
{
    cin>>n>>m>>k;
    int sx,sy;
    getchar();
    for(int i=0;i<n;i++)//输入顺便找到起点
    {
        for(int j=0;j<m;j++)
        {
            scanf("%c",&a[i][j]);
            if(a[i][j]=='S')
            {
                sx=i;
                sy=j;
            }
        }
        getchar();
    }
    stmp[sx][sy]=1;
    po.push(make_pair(sx,sy));
    while(!po.empty())
    {
        int x=po.front().first;
        int y=po.front().second;
        ans=min(ans,min(min(x,n-x-1),min(y,m-y-1)));
        po.pop();
        for(int i=0;i<4;i++)
        {
            int xx=x+direction[i][0];
            int yy=y+direction[i][1];
            if(check(xx,yy)&&stmp[x][y]<=k)
            {
               stmp[xx][yy]=stmp[x][y]+1;
               po.push(make_pair(xx,yy));
            }
        }
    }
    int anss;
    anss=1+(ans+k-1)/k;//向上取整
    cout<<anss<<endl;
    return 0;
}


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

int main (int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;
    
    while (a!=0 && b!=0)
    {
        int c;
        c = a%b;
        a = b;
        b = c;
    }
    
    cout << a << endl;
    return 0;
}

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

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

    if (A != 7 && B != 7 && C != 7)
    {
        cout << "NO";
    }
    else
    {
        if ((A == 5 && B == 5) || (A == 5 && C == 5) || (B == 5 && C == 5))
        {
            cout << "YES";
        }
        else
        {
            cout << "NO";
        }
    }
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e9+7;
ll pow(ll x,ll y){
  if(y==0) return 1;
  ll ret=pow(x,y/2);
  ret*=ret;
  ret%=mod;
  if(y%2==1) ret*=x;
  return ret%mod;
}
ll frac(ll n){
  ll ret=1;
  for(ll i=1;i<=n;i++){
    ret*=i;
    ret%=mod;
  }
  return ret;
}
ll nCr(ll n,ll r){
  ll ret=frac(n);
  ret*=pow(frac(r),mod-2);
  ret%=mod;
  ret*=pow(frac(n-r),mod-2);
  return ret%mod;
}
int main(){
  ll x,y;
  cin>>x>>y;
  if((x+y)%3!=0){
    cout<<0<<endl;
    return 0;
  }
  if(x==0&&y==0){
    cout<<1<<endl;
    return 0;
  }
  ll t=(x+y)/3;
  ll star=y-t;
//  cout<<t<<" "<<star<<endl;
  if(star>t||star<0){
    cout<<0<<endl;
    return 0;
  }
  cout<<nCr(t,star)<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()
a = readInts()
a.extend(readInts())
ans = 0
for i in range(n):
	pos = 1
	t=a[0]
	for j in range(n):
		if i==j:
			pos+=n-1
		t+=a[pos]
		pos+=1
	ans = max(ans,t)
print(ans)

Measured memory_bytes: 9400
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;

#define rep(i, n) for (int (i) = 0; (i) < (int)(n); ++(i))
#define ALL(s) (s).begin(),(s).end()
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T> ostream& operator<<(ostream &s, set<T> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<*it;}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}

template<class T> bool chmax(T& a, T b) { if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T& a, T b) { if (a > b) {a = b; return 1;} return 0; }



const ll INF = 1LL<<58;
const int MAX = 1010;
int n;
ll x[MAX], y[MAX];

ll dp[MAX][MAX];
ll px[MAX][MAX], py[MAX][MAX];
int kdp[MAX][MAX];


int main() {
    while (cin >> n) {
        for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
        
        for (int i = 0; i < MAX; ++i) for (int j = i; j < MAX; ++j) {
            dp[i][j] = INF;
        }
        for (int i = 0; i < MAX; ++i) {
            dp[i][i+1] = 0;
            px[i][i+1] = x[i];
            py[i][i+1] = y[i];
            kdp[i][i+1] = i;
        }
        
        for (int b = 2; b <= n; ++b) {
            for (int i = 0; i <= n; ++i) {
                int j = i + b;
                
                for (int k = kdp[i][j-1]; k <= kdp[i+1][j]; ++k) {
                    if ( chmin(dp[i][j], dp[i][k] + dp[k][j] 
                               + abs(px[i][k]-px[k][j]) + abs(py[i][k]-py[k][j])) ) {
                        px[i][j] = min(px[i][k], px[k][j]);
                        py[i][j] = min(py[i][k], py[k][j]);
                        kdp[i][j] = k;
                    }
                }
            }
        }
    
        cout << dp[0][n] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 28536
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      ta: [(usize, usize); n]
   }
   let mut tn = ta[0].0;
   let mut an = ta[0].1;
   for i in 1..n {
      let (t, a) = ta[i];
      let r = std::cmp::max((tn-1)/t, (an-1)/a) + 1; 
      tn = t * r;
      an = a * r;
   }
   println!("{}", tn + an);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N = 100005;
int n;
bool A[N], ans[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    cin >> n;
    string s;
    cin >> s;
    REP(i,n) {
        if(s[i]=='o') A[i]=0;
        else A[i]=1;
    }

    REP(i, 2) {
        REP(j, 2) {
            ans[0]=i; ans[1]=j;
            for(int k=2; k<n; k++) {
                ans[k] = A[k-1]^ans[k-1]^ans[k-2];
            }

            if(A[n-1]^ans[n-1]^ans[0]^ans[n-2]) continue;
            if(A[0]^ans[0]^ans[1]^ans[n-1]) continue;

            for(int i=0; i<n; i++) {
                if(ans[i]) cout << 'W';
                else cout << 'S';
            }
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}

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

using namespace std;

string s;

int a, b, c, d;

int main() {
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'N') {
            d = 1;
        }
        if (s[i] == 'E') {
            a = 1;
        }
        if (s[i] == 'W') {
            c = 1;
        }
        if (s[i] == 'S') {
            b = 1;
        }
    }
    if ((d + b == 2 && a + c == 0) || (a + c == 2 && d + b == 0) || (a + b + c + d == 4)) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T>
using ost = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
#define forn(i,n) for(int i=0; i<int(n); ++i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define ff first
#define ss second

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi xs(2*n);
    for (int& x:xs) cin>>x;
    sort(all(xs));
    int ans=0;
    for (int i=0; i<n; ++i) ans+=xs[2*i];
    cout << ans << '\n';
}


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

int main()
{
    int n, d, cnt = 0;

    scanf("%d%d", &n, &d);

    for (int i = 0; i < n; i++) {
        int x, y;
        long double dist;
        scanf("%d%d", &x, &y);
        dist = sqrtl((long double)x * x + (long double)y * y);
        if (dist <= d)
            cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 2152
#include<stdio.h>
int main(){
  double sum=0.0;
  int m,i,n;
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&n);
    sum+=(double)(n);
  }
  printf("%.0f\n",sum/i);
  return 0;
}

Measured memory_bytes: 628
#include <stdio.h>

int Partition(int *,int,int);
void swap(int *,int,int);

int main(){
  int i,n;
  int cen;
  int a[100000];

  scanf("%d",&n);

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

  cen = Partition(a,0,n-1);

  for(i=0;i<n-1;i++){
    if(i == cen) printf("[%d] ",a[i]);
    else printf("%d ",a[i]);
  }
  if(i == cen)printf("[%d]\n",a[i]);
  else printf("%d\n",a[i]);

  return 0;
}

int Partition(int *a,int p,int r){
  int i,j,x,box;

  x=a[r];
  j=p-1;

  for(i=p;i<r;i++){
    if( a[i] <= x){
      j++;
      swap(a,j,i);
    }
  }
  swap(a,j+1,r);

  return j+1;
}

void swap(int *a,int p,int q){
  int box;

  box = a[p];
  a[p]=a[q];
  a[q]=box;
}

Measured memory_bytes: 988
#include <stdio.h>
#include <math.h>
struct s{
  double x;
  double y;
};
void kock(int n,struct s p1,struct s p2){
  struct s a,b,c;
  if (n>0){
    a.x=(2*p1.x+p2.x)/3;
    a.y=(2*p1.y+p2.y)/3;
    b.x=(p1.x+2*p2.x)/3;
    b.y=(p1.y+2*p2.y)/3;
    c.x=fabs((b.x-a.x)/2-(b.y-a.y)*sqrt(3)/2+a.x);
    c.y=fabs((b.x-a.x)*sqrt(3)/2+(b.y-a.y)/2+a.y);
    kock(n-1, p1, a);
    printf("%f %f\n",a.x,a.y);
    kock(n-1, a, c);
    printf("%f %f\n",c.x,c.y);
    kock(n-1, c, b);
    printf("%f %f\n",b.x,b.y);
    kock(n-1, b, p2);
  }
}
int main(){
  int n;
  struct s p1={0,0};
  struct s p2={100,0};
  scanf("%d",&n);
  printf("%f %f\n",p1.x,p1.y);
  kock(n, p1, p2);
  printf("%f %f\n",p2.x,p2.y);
  return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	ll n,m;
	cin >> n >> m;
	if(n*2>=m){
		cout << m/2 << endl;
	}else{
		cout << n + (m - n*2)/4 << endl;
	}

  return 0;
}


Measured memory_bytes: 256
N, M  = map(int, input().split())
x_min, x_max = [], []
for i in range(M):
  L, R = map(int, input().split())
  x_min.append(L)
  x_max.append(R)
  
if min(x_max) - max(x_min) >= 0:
  print(min(x_max) - max(x_min) + 1)
else:
  print(0)

Measured memory_bytes: 11052
//ΔARC090C
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 111111*2;
const int M = 222222*2;
const int mod = 1e9+7;
const LL INF = (LL)1e18;
struct edge{
	int to;
	LL dis;
	int pr;
}e[M<<1];
int tot=1,la[N];
void clr(){
	tot=1;
	memset(la,0,sizeof(la));
}
void adde(int x,int y,int z){
	tot++;
	e[tot].to=y;
	e[tot].dis=z;
	e[tot].pr=la[x];
	la[x]=tot;
}
int n;
LL dd,ds[N],dt[N];
bool h[N];
int m,x[M],y[M];
LL z[M],f[M];
bool r[M];
int s,t;
pair<LL,int> p[N];
int dp1[N],dp2[N];
vector<int> c;
priority_queue<pair<LL,int> > Q;
LL d[N];
void dijk(int w){
	int i,x,y;
	LL l,z;
	for(i=0;i<N;i=i+1)
		d[i]=INF;
	d[w]=0;
	Q.push(make_pair(-d[w],w));
	while(!Q.empty()){
		x=Q.top().second;
		l=Q.top().first;
		Q.pop();
		if(d[x]!=-l)
			continue;
		for(i=la[x];i;i=e[i].pr){
			y=e[i].to;
			z=e[i].dis;
			if(d[y]>d[x]+z){
				d[y]=d[x]+z;
				Q.push(make_pair(-d[y],y));
			}
		}
	}
}
int main()
{
	int i,j,xx,yy;
	LL zz,ans,ss;
	scanf("%d%d%d%d",&n,&m,&s,&t);
	for(i=1;i<=m;i=i+1){
		scanf("%d%d%lld",&xx,&yy,&zz);
		x[i]=xx,y[i]=yy,z[i]=zz;
		adde(xx,yy,zz);
		adde(yy,xx,zz);
	}
	dijk(s);
	for(i=1;i<=n;i=i+1)
		ds[i]=d[i];
	dijk(t);
	for(i=1;i<=n;i=i+1)
		dt[i]=d[i];
	dd=ds[t];
	for(i=1;i<=n;i=i+1)
		if(ds[i]+dt[i]==dd&&ds[i]==dt[i])
			h[i]=1;
	for(i=1;i<=m;i=i+1){
		xx=x[i],yy=y[i],zz=z[i];
		if(h[xx]|h[yy])
			continue;
		for(j=0;j<=1;j=j+1){
			if(ds[xx]+dt[yy]+zz==dd)
				if(ds[xx]+zz>dt[yy]&&ds[xx]<dt[yy]+zz)
					r[i]=1;
			swap(xx,yy);
		}
	}
	for(i=1;i<=n;i=i+1)
		p[i]=make_pair(ds[i],i);
	sort(p+1,p+n+1);
	dp1[s]=1;
	for(j=1;j<=n;j=j+1){
		xx=p[j].second;
		for(i=la[xx];i;i=e[i].pr){
			yy=e[i].to;
			zz=e[i].dis;
			if(ds[xx]+dt[yy]+zz==dd){
				f[i>>1]=dp1[xx];
				dp1[yy]=(dp1[yy]+dp1[xx])%mod;
			}
		}
	}
	for(i=1;i<=n;i=i+1)
		p[i]=make_pair(dt[i],i);
	sort(p+1,p+n+1);
	dp2[t]=1;
	for(j=1;j<=n;j=j+1){
		xx=p[j].second;
		if(h[xx])
			c.push_back((LL)dp1[xx]*dp2[xx]%mod);
		for(i=la[xx];i;i=e[i].pr){
			yy=e[i].to;
			zz=e[i].dis;
			if(dt[xx]+ds[yy]+zz==dd){
				if(r[i>>1])
					c.push_back((LL)f[i>>1]*dp2[xx]%mod);
				dp2[yy]=(dp2[yy]+dp2[xx])%mod;
			}
		}
	}
	ans=0,ss=0;
	i=c.size();
	while(i--){
		j=c[i];
		ss=(ss+j)%mod;
		ans+=(LL)j*j%mod;
		ans%=mod;
	}
	ans=mod-ans+(LL)ss*ss%mod;
	printf("%d",ans%mod);
	return 0;
}

Measured memory_bytes: 34036
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <queue>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <random>
#include <functional>

using namespace std;

#define F first
#define S second
#define pb push_back
#define epr(...) fprintf(stderr, __VA_ARGS__)
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"; 
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"
#define dbv(a) cerr << #a << ": "; for (auto& xxxx: a) cerr << xxxx << " "; cerr << endl;
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)a.size()
#define pw(n) (1ll << (n))
#define equal equalll
#define less lesss

typedef double dbl;
typedef long long ll;
const int N = -1;
const int INF = 1.01e9;
typedef vector<int> vi;



int main() {
#ifdef HOME 
    assert(freopen("in", "r", stdin));
#endif
    int n;
    scanf("%d", &n);
    vector<int> have(13);
    have[0]++;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        have[x]++;
    }
    for (int i = 0; i < 13; i++) {
        if (have[i] > 2 || have[0] > 1 || have[12] > 1) {
            puts("0");
            return 0;
        }
    }

    int answer = 0;

    for (int mask = 0; mask < pw(11); mask++) {
        vector<int> res(24); 
        res[0] = 1;
        if (have[12]) {
            res[12] = 1;
        }

        for (int i = 0; i < 11; i++) {
            if (have[i + 1]) {
                if ((mask & pw(i)) || have[i + 1] == 2) {
                    res[i + 1] = 1;
                }
                if ((mask & pw(i)) == 0 || have[i + 1] == 2) {
                    res[24 - (i + 1)] = 1;
                }
            }
        }
        int s = INF;
        for (int i = 0; i < 24; i++) {
            if (res[i]) {
                for (int j = 1; ; j++) {
                    if (res[(i + j) % 24]) {
                        s = min(s, j);
                        break;
                    }
                }
            }
        } 
        answer = max(answer, s);
    }
    cout << answer << endl;





    
#ifdef HOME 
    epr("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
#endif
    return 0;
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF 10000000
#define MOD 998244353
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  int y=0;
  int n=0;
  int two=0;
  for(int i=0;i<N;i++){
    if(a[i]%4==0)y++;
    else if(a[i]%2)n++;
    else two++;
  }
  if(two)n++;
  bool ans;
  if((n+y)%2){
    if(n<=y+1)ans=true;
    else ans=false;
  }
  else{
    if(n<=y)ans=true;
    else ans=false;
  }
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = 0;
		
		if(a < b) c = b - (a+w);
		if(b < a) c = a - (b+w);

		if(a == b || c < 0){
			System.out.println(0);
		} else {
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;


int main(){

	char buf[101],current;
	bool Lost;

	while(true){
		scanf("%s",buf);
		if(buf[0] == '#')break;

		current = 'A';

		Lost = false;
		for(int i = 0; buf[i] != '\0';i++){
			if(buf[i] == '0'){
				switch(current){
				case 'A':
					current = 'X';
					break;
				case 'X':
					Lost = true;
					break;
				case 'Y':
					current = 'X';
					break;
				case 'Z':
					current = 'W';
					break;
				case 'W':
					current = 'B';
					break;
				case 'B':
					current = 'Y';
					break;
				}
				if(Lost)break;
			}else{
				switch(current){
				case 'A':
					current = 'Y';
					break;
				case 'X':
					current = 'Z';
					break;
				case 'Y':
					Lost = true;
					break;
				case 'Z':
					current = 'B';
					break;
				case 'W':
					current = 'Y';
					break;
				case 'B':
					current = 'X';
					break;
				}
				if(Lost)break;
			}
		}

		if(Lost || current != 'B'){
			printf("No\n");
		}else{
			printf("Yes\n");
		}
	}

    return 0;
}

Measured memory_bytes: 2620
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

int main() {
  long n,a[110000],b[110000];
  cin >> n;
  for(int i = 0; i < n+1; i++)
      cin >> a[i];
  for(int i = 0; i < n; i++)
      cin >> b[i];
  
  long cnt = 0;
  for(int i = 0; i < n; i++) {
    if(b[i] <= a[i]) cnt += b[i];
    else {
      if(a[i+1] - b[i] + a[i] >= 0) {
        cnt += b[i];
        a[i+1] -= (b[i] - a[i]);
      }
      else {
        cnt += a[i] + a[i+1];
        a[i+1] -= (b[i] - a[i]);
        if(a[i+1] < 0) a[i+1] = 0;
      }
    }
  }
  cout << cnt << endl;
}

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

void bubbleSort(vector<pair<char, int>> &A, int N) {
  bool flag = 1;
  for (int i = 0; flag; i++) {
    flag = 0;
    for (int j = N - 1; j >= i; j--) {
      if (A[j].second < A[j - 1].second) {
        swap(A[j], A[j - 1]);
        flag = 1;
      }
    }
  }
}

void selectionSort(vector<pair<char, int>> &A, int N) {
  for (int i = 0; i < N; i++) {
    int minj = i;
    for (int j = minj; j < N; j++) {
      if (A[minj].second > A[j].second) {
        minj = j;
      }
    }
    if (i == minj) {
      continue;
    }
    swap(A[i], A[minj]);
  }
};


int main() {
  int N;
  cin >> N;
  vector<pair<char, int>> A(N);
  vector<pair<char, int>> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i].first >> A[i].second;
    B[i].first = A[i].first;
    B[i].second = A[i].second;
  }

  bubbleSort(A, N);
  selectionSort(B, N);

  bool isStable = true;

  for (int i = 0; i < N; i++) {
    if (i == N - 1) {
      cout << A[i].first << A[i].second << endl;
    } else {
      cout << A[i].first << A[i].second << ' ';
    }
  }
  cout << "Stable" << endl;

  for (int i = 0; i < N; i++) {
    if (A[i].first != B[i].first) {
      isStable = false;
    }

    if (i == N - 1) {
      cout << B[i].first << B[i].second << endl;
    } else {
      cout << B[i].first << B[i].second << ' ';
    }
  }

  if (isStable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
};



Measured memory_bytes: 3128
L,R=map(int,input().split())
if R-L > 2019:
    print(0)
else:
    answers = []
    for a in range(L, R + 1):
        answers.append(a % 2019)
    answer=[]
    for a in range(len(answers)-1):
        for b in range(a+1,len(answers)):
            answer.append((answers[a]*answers[b])%2019)
    print(min(answer))
    

Measured memory_bytes: 107276
#include <iostream>
#include <complex>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

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

typedef complex<double> P;
typedef pair<P, P> L;

const double EPS = 1e-9;
const int INF = 1e9 + 10;

#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)

#define S first
#define T second
#define EX P(INF,INF)

double cross(P a, P b) {
	return (conj(a) * b).Y;
}
double dist(P a, P b) {
	return (a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y);
}
bool isPointOnLine(P a, P b, P c) {
	return abs(a - c) + abs(c - b) < abs(a - b) + EPS;
}

//????????¨?????????????????????
P crosspointLL(P a1, P a2, P b1, P b2) {
	double d1 = cross(b2 - b1, b1 - a1);
	double d2 = cross(b2 - b1, a2 - a1);
	P ret;
	if (EQ(d1, 0) && EQ(d2, 0)) {
		ret = a1;
	}else
	if (EQ(d2, 0)) {
		return EX;
	}else {
		ret = a1 + d1 / d2 * (a2 - a1);
	}
	if (isPointOnLine(b1, b2, ret) && isPointOnLine(a1, a2, ret)) {
		return ret;
	}
	else {
		return EX;
	}
}
typedef tuple<P, bool, bool> pbb;

int dp[102][2];

signed main() {

	int T;
	cin >> T;
	rep(_, T) {
		int xa, ya, xb, yb, n;
		cin >> xa >> ya >> xb >> yb;
		P A(xa, ya), B(xb, yb);
		cin >> n;
		vector<pbb> vp;
		rep(i, n) {
			int xs, ys, xt, yt, o, l;
			cin >> xs >> ys >> xt >> yt >> o >> l;
			P s(xs, ys), t(xt, yt);
			if (crosspointLL(s, t, A, B) != P(INF, INF)) {
				vp.push_back(pbb(crosspointLL(s, t, A, B), o, l));
			}
		}
		sort(vp.begin(), vp.end(), [&](pbb &t0, pbb &t1) {
			return dist(A, get<0>(t0)) < dist(A, get<0>(t1));
		});
		rep(i, 102)rep(j, 2)dp[i][j] = INF;
		dp[0][0] = dp[0][1] = 0;
		rep(i, vp.size()) {
			int o = get<1>(vp[i]), l = get<2>(vp[i]);
			rep(j, 2) {
				if (o == 1) {
					if (j == l) {
						dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
					}else{
						dp[i + 1][1 - j] = min(dp[i + 1][1 - j], dp[i][j] + 1);
					}
				}else
				if (o == 0) {
					if (j == l) {
						dp[i + 1][1 - j] = min(dp[i + 1][1 - j], dp[i][j] + 1);
					}
					else {
						dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
					}
				}
			}
		}
		int ans = INF;
		rep(j, 2) {
			ans = min(dp[vp.size()][j], ans);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3048
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 

//     String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
int D=Integer.parseInt(nyu);
nyu=sc.nextLine();
int E=Integer.parseInt(nyu);
nyu=sc.nextLine();
int F=Integer.parseInt(nyu);



//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(nyu){
case "H H":
System.out.println("H") ;
break;

case "D D":
System.out.println("H") ;
break;

case "H D":
System.out.println("D") ;
break;

case "D H":
System.out.println("D") ;
break;


default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:bo){
//if(tem.equals(nyu))res="vowel";
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



//if(A+B==C || B+C==A || C+A==B){
//double res=Math.ceil((AB)/2);

//System.out.println("Yes");
//}else if(B<A){
//System.out.println("Alice");

//}else{
System.out.println((D+E)*F / 2);
//}




	}
}

Measured memory_bytes: 21712
#include<bits/stdc++.h>
using namespace std;
string lcs(string text1, string text2) {
        
        int n=text1.length();
        int m=text2.length();
        // if(n==0)
        //     return m;
        // if(m==0)
        //     return n;
        int dp[n+1][m+1];
       // memset(dp,0,sizeof(dp));
        
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=m;j++)
            {
                if(i==0||j==0)
                    dp[i][j]=0;
                else if(text1[i-1]==text2[j-1])
                {
                    dp[i][j]=1+dp[i-1][j-1];
                }
                else
                {
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }
            }
        }

        int len=dp[n][m];
        //cout<<len;
        int i=n,j=m;
        string ans;
        while(i>0&&j>0)
        {
            if(text1[i-1]==text2[j-1])
            {
                ans+=string(1,text1[i-1]);
                //cout<<text1[i-1];
                i--;
                j--;
                len--;
            }
            else
            {
                if(dp[i-1][j]>dp[i][j-1])
                {
                    i--;
                }
                else
                {
                    j--;
                }
                
            }

        }

        reverse(ans.begin(),ans.end());
        return ans;
    }
int main()
{
    string a,b;
    cin>>a>>b;
    cout<<lcs(a,b);
    return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<algorithm>
using namespace std;
int n, k, cnt = 0, ans;
string a;
int main()
{
	cin >> n >> k >> a;
	for(int i = 1; i < n; i++)
		if(a[i] == 'L' && a[i-1] == 'R')
			++cnt;
	if(cnt >= k)
	{
		ans = n - (cnt-k) * 2;
		if(a[0] == 'L')
			--ans;
		if(a[n-1] == 'R')
			--ans;
		if(ans == n)
			--ans;
		cout << ans << '\n';
		return 0;
	}
	ans = 0;
	if(a[0] == 'L')
		++ans;
	if(a[n-1] == 'R')
		++ans;
	ans = max(1,ans-k+cnt);
	cout << n-ans << '\n';
	return 0;
}

Measured memory_bytes: 512
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	int range[100003] = { 0 };
	int n;
	int ans = 0;

	cin >> n;
	rep(i, 0, n) {
		int a;
		cin >> a;
		range[a+1]++;range[a]++;range[a + 2]++;
	}

	rep(i, 0, 100002) {
		ans = max(ans, range[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
n,k = map(int,input().split())
mod = 10**9 + 7

ans = 1
for i in range(k,n+1):
    low = i*(i-1)//2
    high = n*(n+1)//2 - (n-i)*(n-i+1)//2
    ans += high - low + 1
    ans %= mod
print(ans)

Measured memory_bytes: 9188
function divisor(n) {var ret=[]; for (var i=1;i*i<=n;i++){if(n%i==0){ret.push(i);if(i*i!=n)ret.push(n/i);}}return ret;}
function main(input) {
  const inputs = input.split('\n');
  var n = parseInt(inputs[0], 10);

  var counter = 0;
  for (var i = 0; i <= n; i++) {
    counter += i % 2 == 1 && divisor(i).length == 8 ? 1 : 0;
  }
  console.log(counter);;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7624
#include <stdio.h>

int selectionSort(int A[], int N){
  int i, j, t, sw = 0, minj;
  for (i = 0; i < N; i++){
    minj = i;
    for (j = i; j < N; j++){
      if (A[j] < A[minj])minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
    if (i != minj)sw++;
   }
   return sw;
}

int main(){
  int A[100], N ,i, sw;

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

  sw = selectionSort(A, N);
  
  for(i = 0; i < N; i++){
    if(i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}
       

Measured memory_bytes: 1852
#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
int N,M;
int T[100005];
int A[100005];
long long rez;
multiset<int> G[100005];
int fi(int nod){
    if(T[nod] <= 0){
        return nod;
    }
    return T[nod] = fi(T[nod]);
}
void u(int x,int y,bool baga){
    x = fi(x);
    y = fi(y);
    if(baga){
        rez += *G[x].begin();G[x].erase(G[x].begin());
        rez += *G[y].begin();G[y].erase(G[y].begin());
        T[x]++;
        T[y]++;
    }
    if(T[x] < T[y]){
        for(auto it:G[y]){
            G[x].insert(it);
        }
        T[x] += T[y];
        T[y] = x;
    }
    else{
        for(auto it:G[x]){
            G[y].insert(it);
        }
        T[y] += T[x];
        T[x] = y;
    }
}
class cmp{
    public:
    bool operator() (int a,int b){
        return T[a] > T[b];
    }
};
priority_queue<int,vector<int>,cmp> H;
int main(){
    cin >> N >> M;
    for(int i = 1;i <= N;i++){
        cin >> A[i];
        T[i] = -1;
        G[i].insert(A[i]);
    }
    for(int i = 1;i <= M;i++){
        int x,y;
        cin >> x >> y;
        x++;
        y++;
        u(x,y,0);
    }
    for(int i = 1;i <= N;i++){
        if(T[i] <= 0){
            H.push(i);
        }
    }
    rez = 0;
    while(M < N - 1){
        if(H.size() < 2){
            cout << "Impossible";
            return 0;
        }
        int a = H.top();H.pop();
        int b = H.top();H.pop();
        if(T[b] == 0){
            cout << "Impossible";
            return 0;
        }
        u(a,b,1);
        H.push(fi(a));
        M++;
    }
    cout << rez;
    return 0;
}


Measured memory_bytes: 20224
use std::io;
     
    fn next_vec() -> Vec<i64> {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace().map(|n| n.parse().unwrap()).collect()
    }
     
    fn main() {
        let mut v = next_vec();
        let a = v[0];
        let b = v[1];
        let c = v[2];
     
        let ans = if a % 2 != 0 && b % 2 != 0 && c % 2 != 0 {
            v.sort();
            println!("{}", v[1] * v[0]);
        } else {
            println!("0");
        };
  }

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { -1, 0, 0, 1 };
const ll dy[4] = { 0, -1, 1, 0 };
const ll INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
struct Accelerate_Cin {
	Accelerate_Cin() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
};
///////////////////////////////////////

int main() {
	string s; cin >> s;
	deque<int>que;
	for (int i = 0; i < s.size(); ++i) {
		que.push_back(s[i]);
	}
	int ans = 0;
	while (!que.empty()) {
		if (que.size() == 1)break;
		if (que.front() == 'x'&&que.back() != 'x') {
			que.pop_front();
			ans++;
		}
		else if (que.front() != 'x'&&que.back() == 'x') {
			que.pop_back();
			ans++;
		}
		else if (que.front() == 'x'&&que.back() == 'x') {
			que.pop_back();
			que.pop_front();
		}
		else {
			if (que.front() != que.back()) {
				cout << -1 << endl;
				return 0;
			}
			else {
				que.pop_back();
				que.pop_front();
			}
		}
		if (que.size() == 1)break;
	}
	cout << ans << endl;
	return 0;
}


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

class eratosthenes {
private:
	long long int x;
	int nsqrt;
	int ans = 0;
	vector<bool> sieve;
public:
	eratosthenes(long long int n) {
		x = n;

		nsqrt = sqrtl(x);
		sieve.reserve(nsqrt);

		sieve[0] = false;
		sieve[1] = false;
		for (int i = 2; i <= nsqrt; i++) sieve[i] = true;

		for (int i = 1; i <= nsqrt; i++) {
			if (sieve[i] == false) continue;

			int fac = 0;
			while (x % i == 0) {
				x /= i;
				fac++;
			}

			for (int j = 1; j <= fac; j++) {
				if (fac - j >= 0) {
					fac -= j;
					ans++;
				}
			}

			for (int j = i + i; j <= nsqrt; j += i) sieve[j] = false;
		}
		if (x != 1) ans++;
	}
	void print() {
		cout << ans << endl;
	}
};

int main() {
	long long int n;
	cin >> n;
	eratosthenes e(n);
	e.print();
}

Measured memory_bytes: 3720
import sys
def gcd(x, y):
    while True:
        if x > y:
            x %= y
        else:
            y %= x
        if x == 0 or y == 0:
            break
    return max(x, y)

a, b, c, d = [int(i) for i in sys.stdin.readline().split()]
gcd_cd = gcd(c, d)
lcm = c * d // gcd_cd
n_c = b // c - (a - 1) // c
n_d = b // d - (a - 1) // d
n_cd = b // lcm - (a - 1) // lcm
res = (b - a + 1) - n_c - n_d + n_cd
print(res)

Measured memory_bytes: 38384
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
//const ll MOD = 1000000007;
#define P pair<int, int>
using namespace std;

int main(){
    double T, D, S;
    cin >> D >> T >> S;
    if(T >= (D / S)) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3712
n = int(input())
h = list(map(int, input().split()))

ans = "Yes"
last_max = max(h[0] - 1, 0)
for i in range(n-1):
    if h[i] - h[i+1] > 1:
        ans = "No"
        break     
    elif h[i] - h[i+1] == 1:
        if h[i] - 1 < last_max:
            ans = "No"
            break
        last_max = h[i] - 1
print(ans)


Measured memory_bytes: 14704
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	sort(ALL(v));
	ll ans = 0;
	rep(i,n) {
		for (int j = i + 1; j < n; j++) {
			int p = v[i] + v[j];
			int x = lower_bound(v.begin(), v.end(), p) - v.begin();
			ans = ans + max(x - (j + 1), 0);
		}
	}
	cout << ans << endl;
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3544
n,k = map(int,input().split())

candy_set = set()
for i in range(k):
    d = int(input())
    snuke = list(map(int,input().split()))
    for s in snuke:
        candy_set.add(s)

count = 0
for i in range(n):
    if not i+1 in candy_set:
        count+=1
print(count)

Measured memory_bytes: 9068
#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++)
#define repr(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/
bool rec(int i,int j,char a[10][10]){
    if(a[i][j]=='G')return true;
    if(a[i+1][j]=='#'){
        rec(i+1,j,a);
    }else if(a[i][j+1]=='#'){
        rec(i,j+1,a);
    }else return false;
    return false;
}

int main(){
    int h,w;
    cin >> h >> w;
    char a[10][10];
    memset(a,'.',sizeof(a));
    FOR(i,1,h+1)FOR(j,1,w+1){
        cin >> a[i][j];
    }
    FOR(i,1,h+1)FOR(j,1,w+1){
        if(a[i][j]=='#'){
            if(a[i+1][j]=='#' && a[i+1][j-1]=='#'){
                cout << "Impossible";
                return 0;
            }
            if(a[i-1][j]=='#' && a[i-1][j+1]=='#'){
                cout << "Impossible";
                return 0;
            }
        }
    }
    cout << "Possible";
}

Measured memory_bytes: 256
import sys

def check(matrix):
    S = sum(m[0])
    for i in range(3):
        if S != sum(m[i]):
            return False
    for j in range(3):
        if S != (m[0][j] + m[1][j] + m[2][j]):
            return False
    if S != (m[0][0] + m[1][1] + m[2][2]):
        return False
    if S != (m[0][2] + m[1][1] + m[2][0]):
        return False
    return True
    
def print_matrix(matrix):
    for i in range(3):
        print(" ".join(list(map(str, matrix[i]))))

m = [[None for __ in range(3)] for _ in range(3)]
m[0][0] = int(sys.stdin.readline().strip())
m[0][1] = int(sys.stdin.readline().strip())
m[1][1] = int(sys.stdin.readline().strip())

a = m[0][0]
b = m[0][1]
c = m[1][1]

for n in range(100+1):
    S = a + b + n
    m[0][2] = n
    m[2][0] = (S - n - c)
    m[2][1] = (S - b - c)
    m[1][0] = (S - a - m[2][0])
    m[2][2] = (S - a - c)
    m[1][2] = (S - m[1][0] - m[1][1])
    if check(m):
        print_matrix(m)
    
    


Measured memory_bytes: 3188
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.AbstractMap.SimpleEntry;

class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long ans = 0;
        for (int i = 1; i <= N; i++) {
            ans += N / i * Math.max(0, i - K);
            ans += Math.max(0, N % i - K + 1);
            // System.err.println(i + " " + N / i * Math.max(0, i - K));
            // System.err.println(i + " " + Math.max(0, N % i - K + 1));
        }
        if (K == 0)
            ans -= N;
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  string s; cin >> s;
  stack<char> st;

  int n = s.size();

  for (int i = 0; i < n; ++i) {
    if (st.empty()) {
      st.push(s[i]);
    } else if (st.top() == 'S' && s[i] == 'T') {
      st.pop();
    } else {
      st.push(s[i]);
    }
  }

  cout << (int) st.size() << '\n';

  return 0;
}

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

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

template <typename T>
istream& operator>> (istream &f, vector<T> &a){
    for(auto &el : a){ f >> el; }
    return f;
}

vector<bool> a(10, true);

bool check(int n){
    if(n == 0){
        return a[n];
    }else {
        while (n > 0) {
            if(!a[n%10]){return false;}
            n /= 10;
        }
        return true;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int el;
    for(int i = 0; i < k; ++i){
        cin >> el;
        a[el] = false;
    }
    while(!check(n)){ ++n; }
    cout << n;
}

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


int main(){
    int K;
    cin>>K;
    string S="1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
    if (K<16){
        cout<<S.at(3*K-3)<<endl;
    }
    else if (K==16){
        cout<<"14"<<endl;
    }
    else if (K<24){
        cout<<S.at(3*K-2)<<endl;
    }
    else if (K==24){
        cout<<"15"<<endl;
    }
    else if (K<32){
        cout<<S.at(3*K-1)<<endl;
    }
    else{
        cout<<"51"<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define P(s) cout << s << "\n"

inline void PYN(bool b) {
    b? P("Yes"): P("No");
}

int main() {
    int32_t a, b, c;
    cin >> a >> b >> c;
    
    PYN(a + b >= c);
}

Measured memory_bytes: 256